Hashability of classes, old and new
jcarlson at nospam.uci.edu
Mon Feb 16 20:10:33 CET 2004
> So, despite c1 equals c2, they create two different entries in a
> dictionary. I thought that this is such an inconsistency that was the
> reason behind requiring an explicit `__hash__' for old-style classes.
> So, it seems I was not thinking right, there is something which escapes
> my understanding. Would some kind soul help mine? :-)
When two objects have different hashes, they are not required to be
compared when inserted into a dictionary. They may be compared, if two
hashes drop the objects into the same bin.
More information about the Python-list