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/2003-December/041379.html below:

[Python-Dev] getting rid of default object.__hash__ (SF 660098)

[Python-Dev] getting rid of default object.__hash__ (SF 660098) [Python-Dev] getting rid of default object.__hash__ (SF 660098)Guido van Rossum guido at python.org
Mon Dec 22 16:32:15 EST 2003
> >Since the default hash simply takes id() of the object, it's easy to
> >fix such code once the failure is understood though.
> 
> Jython 2.2a0 on java1.4.0_02 (JIT: null)
> Type "copyright", "credits" or "license" for more information.
>  >>> class C: pass
> ...
>  >>> id(C)
> 1
>  >>> hash(C)
> 9174506
>  >>>
> 
> I see, but then there should be probably be a different way to spell
> the default hash, because id is not a sensible option for Jython etc

Ow, you're right.  I bet this is why object.__hash__ was introduced in
the first place.

We're either back to square one, or we can add a __default_hash__ to
object which has the default hash implementation -- this isn't very
pretty but at least it works.

(I should add that this topic rose to my attention when I had to debug
the issue in some code of my own -- I had a class whose __eq__ was
overridden but whose __hash__ wasn't, and it was being used as a dict
key...  It is indeed a pain to debug this. :-( )

--Guido van Rossum (home page: http://www.python.org/~guido/)

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