#14159: Don't install callbacks on values of TripleDict, MonoDict
---------------------------------+------------------------------------------
       Reporter:  nbruin         |         Owner:  tbd         
           Type:  PLEASE CHANGE  |        Status:  needs_review
       Priority:  major          |     Milestone:  sage-5.8    
      Component:  PLEASE CHANGE  |    Resolution:              
       Keywords:                 |   Work issues:              
Report Upstream:  N/A            |     Reviewers:              
        Authors:  Simon King     |     Merged in:              
   Dependencies:                 |      Stopgaps:              
---------------------------------+------------------------------------------

Comment (by nbruin):

 "Reviewer" patch to provide some doc and pointers if this ever proves to
 be a problem. An example of the kind of situation where this could lead to
 quadratic memory use (relative to what is required):

 {{{
 R=[ZZ.quo(3^n) for n in [1..100]]
 for i in range(100):
     for j in range(i,100):
         H = Hom(R[j],R[i])
 }}}

 This leaves `100*101/2` entries with (eventually) dead weakrefs in the
 dictionary.

 I think we should leave ample documentation of this leak in the code,
 including the strategy to fix it, should it become necessary.

 (for posterity: The KeyedRef alternative is ''probably'' OK, because it
 seems that H can never outlive its domain and codomain X and Y, so I don't
 see how their id's could get reused before the callback on H has happened
 or got purged. I'm just very cautious with anything that has to do with GC
 and callback orders after the problems we encountered with it elsewhere.
 In any case, the incantation would have to documented "DO NOT COPY THIS
 WITHOUT UNDERSTANDING THE CONSEQUENCES FULLY", because it's a bad pattern
 to use elsewhere, unless you prove a whole bunch of extra conditions.)

 Simon, are you OK with the doc? If so we can put this to positive review
 (doctests passed for me)

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14159#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to