Hi,
I was just explaining to a student in my Sage course how I had
stupidly defined a default __hash__ method for SageObject, which was
-- stupidly -- to just hash the string representation. This was of
course silly and dangerous since only immutable objects should have a
__hash__ method. I then of course pointed out that we must have
fixed this years ago! But.... amazingly we didn't:
sage: S = SageObject(); S
<type 'sage.structure.sage_object.SageObject'>
sage: hash(S)
-7904861314369208036
sage: S.__hash__??
File: /sagenb/flask/sage-4.6.2/devel/sage/sage/structure/sage_object.pyx
Source Code (starting at line 156):
def __hash__(self):
return hash(self.__repr__())
Thoughts?
-- William
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org