>> Also, I believe that max "reasonable" integer range of no collision
>> is (-2305843009213693951, 2305843009213693951), ...

> Any range  that does _not_ contain both -2 and -1 (-1 is an annoying
> special case, with hash(-1) == hash(-2) == -2), and spans no more than
> sys.hash_info.modulus integers.  Apart from that, the sign and
> magnitude of the start of the range don't matter; e.g.,
>
> >>> len(set(hash(i) for i in range(10**5000, 10**5000 + 1000000)))
> 1000000
> >>> len(set(hash(i) for i in range(-10**5000, -10**5000 + 1000000)))
> 1000000

Sorry again!  That only shows that the hash codes are unique.  Dicts
and sets use only the last N bits to determine the start of the probe
sequence, for some value of N >= 3 (depending on the table size).  So
for a table of size a million, the last 20 bits (1000000 ~= 2**20) are
interesting.  But same thing:

>>> MASK = (1 << 20) - 1
>>> len(set(hash(i) & MASK for i in range(-10**5000, -10**5000 + 1000000)))
1000000
>>> len(set(hash(i) & MASK for i in range(-10**5000, -10**5000 + 1000000)))
1000000
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BXHOS73YMJDSVZUM74VYXXYN5WW63BZ4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to