-
-
Notifications
You must be signed in to change notification settings - Fork 656
Closed
Description
In #11900, a cache has been introduced to sage.rings.ring.is_Field, in order to speed things up. Unfortunately, that caused the following leak:
sage: p = 1
sage: import gc
sage: gc.collect()
662
sage: for i in range(100):
....: p = next_prime(p)
....: R = ZZ.quotient(p)
....: t = R in Fields()
....: _ = gc.collect()
....: print len([X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]),
....:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
I think the cleanest solution is:
- deprecate is_Field
- instead, use an uncached function _is_Field
- in the sage tree, replace
is_Field(R)
byR in Fields()
Rationale:
is_Field(R) (or _is_Field(R)) will change R.category() into a sub-category of Fields(). But then, the next call to "R in Fields()" will be very fast. Hence, there is no reason (speed-wise) to cache is_Field. Actually, R in Fields()
should be faster than is_Field(R)
anyway, because of the cythonisation.
Depends on #11310
Depends on #12215
Depends on #11521
Depends on #12313
Depends on #13089
Depends on #12995
Component: memleak
Author: Simon King
Reviewer: Nils Bruin
Merged: sage-5.8.beta0
Issue created by migration from https://trac.sagemath.org/ticket/13370