[issue5186] Reduce hash collisions for objects with no __hash__ method
report at bugs.python.org
Thu Feb 12 22:33:34 CET 2009
Adam Olsen <rhamph at gmail.com> added the comment:
Antoine, x ^= x>>4 has a higher collision rate than just a rotate.
However, it's still lower than a statistically random hash.
If you modify the benchmark to randomly discard 90% of its contents this
should give you random addresses, reflecting a long-running program.
Here's the results I got (I used shift, too lazy to rotate):
XOR, sequential: 20.174627065692999
XOR, random: 30.460708379770004
shift, sequential: 19.148091554626003
shift, random: 30.495631933229998
original, sequential: 23.736469268799997
original, random: 33.536177158379999
Not massive, but still worth fixing the hash.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list