A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-May/111531.html below:

[Python-Dev] Python 3.x and bytes

[Python-Dev] Python 3.x and bytes [Python-Dev] Python 3.x and bytesNick Coghlan ncoghlan at gmail.com
Fri May 20 11:21:24 CEST 2011
On Fri, May 20, 2011 at 10:40 AM, Ethan Furman <ethan at 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   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4