[Python-3000] __hash__ : Problem with either documentation or understanding

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jul 30 03:11:20 CEST 2008


Nick Coghlan wrote:

> Objects which compare equal must also end up in the same hash bucket in 
> order for dictionaries to work correctly.

And, if its equality with another object can change during
its lifetime, it will never work properly in a dictionary.
So in that case you should leave __hash__ unimplemented so
that you can't accidentally use one as a dict key.

-- 
Greg


More information about the Python-3000 mailing list