#14159: Don't install callbacks on values of TripleDict, MonoDict
---------------------------------+------------------------------------------
Reporter: nbruin | Owner: tbd
Type: PLEASE CHANGE | Status: new
Priority: major | Milestone: sage-5.8
Component: PLEASE CHANGE | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
---------------------------------+------------------------------------------
Comment (by nbruin):
You have to make sure that the weakref object lives to see the death of v
(and ensure that you make such a weakref in the first place!)
{{{
sage: from sage.structure.coerce_dict import TripleDict
sage: import gc
sage: import weakref
sage: class Foo: pass
sage:
sage: a = 1
sage: b = 2
sage: c = 3
sage: v = Foo()
sage: w = Foo()
sage: T = TripleDict(13)
sage: T[a,b,c] = weakref.KeyedRef(v,T.eraser,(id(a),id(b),id(c)))
sage: h=T[a,b,c]
sage: T[a,b,c] = w
sage: del v
sage: _ = gc.collect()
sage: len([x for x in gc.get_objects() if isinstance(x,Foo)])
1
sage: T[a,b,c] == w
KeyError: (1, 2, 3)
}}}
I admit, the weakref surviving outside the dict is not a terribly likely
event, but from your code at #11521 it wasn't entirely clear to me that
you can absolutely rule it out.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14159#comment:7>
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.