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/2012-May/119540.html below:

[Python-Dev] cpython: Describe the default hash correctly, and mark a couple of CPython

[Python-Dev] cpython: Describe the default hash correctly, and mark a couple of CPythonNick Coghlan ncoghlan at gmail.com
Sun May 20 12:58:02 CEST 2012
On Sun, May 20, 2012 at 8:09 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Sun, 20 May 2012 10:31:01 +0200
> nick.coghlan <python-checkins at python.org> wrote:
>> +
>> +   .. impl-detail::
>> +
>> +      CPython uses ``hash(id(x))`` as the default hash for class instances.
>
> This isn't true:
>
>>>> class C: pass
> ...
>>>> c = C()
>>>> hash(c)
> 619973
>>>> id(c)
> 9919568
>>>> hash(id(c))
> 9919568
> id(...) always has the lower bits clear, so it was decided to shift it
> to the right by a number of bits.

Ah, you're right - I misread my own experiment. Regardless, the
hash(c) == id(c) that *was* there was also wrong. I'll just drop the
implementation detail entirely and leave the new wording on its own.

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