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/2005-November/057923.html below:

[Python-Dev] Why should the default hash(x) == id(x)?

[Python-Dev] Why should the default hash(x) == id(x)? [Python-Dev] Why should the default hash(x) == id(x)?"Martin v. Löwis" martin at v.loewis.de
Sun Nov 6 11:08:22 CET 2005
Noam Raphael wrote:
> The alternative is to drop the __hash__ method of user-defined classes
> (as Guido already decided to do), and to make the default __eq__
> method compare the two objects' __dict__ and slot members.

The question then is what hash(x) would do. It seems that you expect
it then somehow not to return a value. However, under this patch,
the fallback implementation (use pointer as the hash) would be used,
which would preserve hash(x)==id(x).

> See the thread about default equality operator - Josiah Carlson posted
> there a metaclass implementing this equality operator.

This will likely cause a lot of breakage. Objects will compare equal
even though they conceptually are not, and even though they did not
compare equal in previous Python versions.

Regards,
Martin
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