Changes between Version 1 and Version 2 of Ticket #13447, comment 27

09/17/12 05:56:44 (7 years ago)


  • Ticket #13447, comment 27

    v1 v2  
    3030The `_parent` attribute is a cython slot. However, it holds a reference to a python-managed object, so I think cython ensures it's properly taken into account in GC cycle counting. But that would suggest to me python could clear this slot to break cycles! So in that case, `Polynomial_template` is never safe. It could be I'm wrong, however.
    32 I haven't been able to locate what `parent._modulus` is in this case. I'd assume that's a cython slot too. Then that access would be just as safe as the `._parent` lookup before.
    33 At this point perhaps Martin Albrecht, Robert Bradshaw and Yann Laigle-Chapuy can give some enlightenment about the design of the templates and their use in `Polynomial_ZZ_pEX`.
     32I haven't been able to locate what `parent._modulus` is in this case. However,
     34sage: K.<a>=GF(next_prime(2**60)**3)
     35sage: R.<x> = PolynomialRing(K,implementation='NTL')
     36sage: '_modulus' in  R.__dict__.keys()
     39suggests this attribute is stored in a dictionary. It's set in `sage.rings.polynomial.polynomial_ring.PolynomialRing_field.__init__`:1367
     41        if implementation == "NTL" and is_FiniteField(base_ring) and not(sparse):
     42            from sage.libs.ntl.ntl_ZZ_pEContext import ntl_ZZ_pEContext
     43            from sage.libs.ntl.ntl_ZZ_pX import ntl_ZZ_pX
     44            from sage.rings.polynomial.polynomial_zz_pex import Polynomial_ZZ_pEX
     46            p=base_ring.characteristic()
     47            self._modulus = ntl_ZZ_pEContext(ntl_ZZ_pX(list(base_ring.polynomial()), p))
     48            element_class = Polynomial_ZZ_pEX
     50I guess we've just found that this is not a very good place to store `_modulus`. Where else, though? Would it be enough to have a cythonized version of `PolynomialRing_field` so that `_modulus` can be tied a little tighter to the parent? It seems to me the parent is the right place to store this information. We just need to convince the parent to hold on to its information for a bit longer.