[sage-devel] Re: Customizing hash for an instance of ?

Sun, 11 Sep 2011 11:35:00 -0700

I've found the python documentation on this exact behaviour of hash and 
other special methods by accident (I was looking for something else in the 
python docs). For a total understanding read 3.4.11 and 3.4.12 
of 
http://docs.python.org/reference/datamodel.html#special-method-lookup-for-old-style-classes
 
.

If you don't want to read it yourself, the reason for the change is that 
newstyle classes are also objects.
sage: class Foo(object):
....:     pass
....: 
sage: isinstance(Foo,object)
True

So if hash called __hash__ for the instance itself first this would lead to 
problems if the instance itself was a class whose instances are hashable.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to