Tim Peters <t...@python.org> added the comment:

> So my suggestion remains
>
> for y in INPUT:
>    t = hash(y)
>    t ^= t * SOME_LARGE_EVEN_NUMBER
>    h ^= t
>    h *= MULTIPLIER

On the face of it, I'd be amazed if that passed SMHasher, because it only 
propagates bits "to the left".  All hashes that score well on that test work to 
propagate "to the right" too.  SeaHash does that with its variable-count 
right-shift-xor.  Another popular choice in other hashes is a rotate.

As noted several times before, our tuple tests only use small integers, where 
there's virtually no variation in the high-order hash bits beyond "all 0" or 
"all 1".  Since all the variation is in a handful of low-order bits, "propagate 
right" _appears_ to be a waste of time.

If we, e.g., tested tuples of little floats instead, we may have "concluded" 
that it's "propagate left" that's a waste of time:

>>> for i in range(5):
...     x = 1 / 2**i
...     print(x, hex(hash(x)
...
1.0                   0x1
0.5    0x1000000000000000
0.25    0x800000000000000
0.125   0x400000000000000
0.0625  0x200000000000000

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34751>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to