On Fri, May 20, 2011 at 10:40 AM, Ethan Furman <et...@stoneleaf.us> wrote: > This behavior matches what I was imagining for having > b'a' == 97. They compare equal, yet remain distinct objects > for all other purposes. > > If anybody has a link to or an explanation why equal values must be equal > hashes I'm all ears. My apologies in advance if this is an incredibly naive > question.
Because whether or not two objects can coexist in the same hash table should *not* depend on their hash values - it should depend on whether or not they compare equal to each other. The use of hashing should just be an optimisation, not fundamentally change the nature of the comparison operation. (i.e. "hash(a) == hash(b) and a == b" is meant to be a fast alternative to "a == b", not a completely different check). Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com