#14471: Exception KeyError: in WeakValueDictionary remove ignored
---------------------------+------------------------------------------------
Reporter: vbraun | Owner: rlm
Type: defect | Status: new
Priority: major | Milestone: sage-5.10
Component: memleak | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
---------------------------+------------------------------------------------
Changes (by nbruin):
* cc: nthierry (added)
Comment:
I think this illustrates the problem rather well:
{{{
sage: f(x,y) = x^2+y
sage: P=parent(f)
sage: P.__class__
sage.symbolic.callable.CallableSymbolicExpressionRing_class
sage: H=hash(P.__class__)
sage: m = matrix([[f,f*f],[f^3,f^4]])
sage: H == hash(P.__class__)
True
sage: hasattr(m,'a')
False
sage: P.__class__
sage.symbolic.callable.CallableSymbolicExpressionRing_class_with_category
sage: H == hash(P.__class__)
False
}}}
We have that P.__hash__ looks like:
{{{
def __hash__(self):
return hash((self.__class__, self._arguments))
}}}
Obviously, when class is not fixed, it's a bad ingredient for a hash.
Given that
{{{
sage: T=type(P)
sage: [t for t in T.mro() if '__hash__' in t.__dict__]
[sage.symbolic.callable.CallableSymbolicExpressionRing_class,
sage.symbolic.ring.SymbolicRing,
sage.structure.category_object.CategoryObject,
sage.structure.sage_object.SageObject,
object]
}}}
we do need to do something about hashing, since
`sage.symbolic.ring.SymbolicRing.__hash__` is just a fixed value and these
CallableExpression rings do come in different flavours. The `__cmp__`
method there also depends on `self.__class__` which should obviously not
be relied upon.
Given that this code stems from #5930, it predates these dynamic classes
voodoo by quite a bit, so the fact that it doesn't operate well with it is
a bug in the dynamic classes stuff. A job for Simon, Nicholas and the
gang!
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14471#comment:13>
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.