Changes between Version 5 and Version 7 of Ticket #715

Jul 4, 2011, 8:38:12 AM (11 years ago)
Jean-Pierre Flori

With the piece of code in the desrciption, there is only one reference to these objects in that ZZ._hash_actions dictionary because to build it we test if A1 == A2 and not A1 is A2 as in coercion_model._action_maps, and because of the current implementation of ellitpic curves, see and #11474, and decause the above code use only one j-invariant, only ones gets finally stored.

However with random curves, I guess there would be all of them.

About the weakref, the idea should more be to build something like WeakKeyDictionnary? if it does not slow down coercion too much...


  • Ticket #715

    • Property Cc Jean-Pierre Flori added
  • Ticket #715 – Description

    v5 v7  
    1 (Moving this to "coercion", which is clearly where it belongs.)
     1Here is a small example illustrating the issue.
     3The memory footprint of the following piece of code grows indefinitely.
     6sage: K = GF(1<<55,'t')
     7sage: a = K.random_element()
     8sage: while 1:
     9....:     E = EllipticCurve(j=a); P = E.random_point(); 2*P; del E, P;
     12E and P get deleted, but when 2*P is computed, the action of integers on A, the abelian group of rational points of the ellitpic curve, gets cached in the corecion model.
     14A key-value pair is left in coercion_model._action_maps dict:
     16(ZZ,A,*) : IntegerMulAction
     18Moreover there is at least also references to A in the IntegerMulAction and one in ZZ._action_hash.
     20So weak refs should be used in all these places if it does not slow things too much.