#11521: Use weak references to cache homsets
--------------------------------------------------+-------------------------
       Reporter:  jpflori                         |         Owner:  robertwb    
     
           Type:  defect                          |        Status:  needs_work  
     
       Priority:  major                           |     Milestone:  sage-5.3    
     
      Component:  coercion                        |    Resolution:              
     
       Keywords:  sd35                            |   Work issues:              
     
Report Upstream:  N/A                             |     Reviewers:  Jean-Pierre 
Flori
        Authors:  Simon King                      |     Merged in:              
     
   Dependencies:  #12969; to be merged with #715  |      Stopgaps:              
     
--------------------------------------------------+-------------------------

Comment (by SimonKing):

 Another comment: I use a weak reference to H (the homset) on the one hand,
 and a weak reference to the category C as the third argument to the
 `TripleDict`, on the other hand (see line 212). Since the keys of a
 `TripleDict` are compared by identity and not by equality, I can not use a
 callback function in the weak reference to C. Namely, weakref.ref(C) is
 identical with weakref.ref(C), whereas two weak references with callback
 are equal but not identical.

 In conclusion, I will use a callback in the weak reference to H, so that
 the dictionary item gets collected as soon as H gets collected. But I
 think I can not use a callback in the weak reference to C. Anyway, a
 callback for C is not needed: If H is alive, it has a reference to C and
 keeps C alive. If H dies, then the callback for the weak reference to H
 will remove the item, and thus C can be collected as well.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11521#comment:147>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to