En Thu, 28 Jun 2007 11:38:56 -0300, A.T.Hofkamp <[EMAIL PROTECTED]>  
escribió:

> The point I intended to make was that having a default __hash__ method on
> objects give weird results that not everybody may be aware of.
> In addition, to get useful behavior of objects in sets one should  
> override
> __hash__ anyway, so what is the point of having a default  
> object.__hash__ ?

__hash__ and equality tests are used by the dictionary implementation, and  
the default implementation is OK for immutable objects. I like the fact  
that I can use almost anything as dictionary keys without much coding.
This must always be true: (a==b) => (hash(a)==hash(b)), and the  
documentation for __hash__ and __cmp__ warns about the requisites (but  
__eq__ and the other rich-comparison methods are lacking the warning).

-- 
Gabriel Genellina
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to