Planning a Python Course for Beginners
Chris Angelico
rosuav at gmail.com
Thu Aug 10 17:05:53 EDT 2017
On Fri, Aug 11, 2017 at 6:56 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> On Fri, Aug 11, 2017 at 6:03 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> I see no point in CPython's rotation magic.
>>
>> Have you ever implemented a hashtable? The most common way to pick a
>> bucket for an object is to use modulo on the number of buckets.
>
> Like I said earlier, CPython takes the __hash__() value and scrambles
> it. Look for "perturb" in:
>
> <URL: https://github.com/python/cpython/blob/master/Objects/dictobject.c>
>
> From a comment:
>
> Now the probe sequence depends (eventually) on every bit in the hash
> code, and the pseudo-scrambling property of recurring on 5*j+1 is
> more valuable, because it quickly magnifies small differences in the
> bits that didn't affect the initial index.
I'm aware of this. Doesn't change the fact that the *INITIAL INDEX* is
based on exactly what I said.
Yaknow?
ChrisA
More information about the Python-list
mailing list