Best practice for caching hash

Cameron Simpson cs at cskk.id.au
Wed Mar 16 08:04:55 EDT 2022


On 16Mar2022 19:09, Chris Angelico <rosuav at gmail.com> wrote:
>On Wed, 16 Mar 2022 at 18:48, Cameron Simpson <cs at cskk.id.au> wrote:
>> This may be because the "raw" hash (in this case the int value) is
>> itself further hashed (giving more evenness) and then moduloed into the
>> finite number of slots in the dict.
>
>Not in a CPython dict, no. (There is some collision management that
>uses upper bits, but the initial selection of bucket simply uses the
>raw hash.) See comments at the top of dictobject.c.

Thank you, I stand corrected. That's a very interesting read.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list