[Python-Dev] String hash function multiplier

Raymond Hettinger raymond.hettinger at verizon.net
Tue Apr 13 19:59:53 EDT 2004

Does anyone have any issues with changing the hash multiplier for the
string and Unicode hash functions?

Instead of 1000003, I would like to use Aho's 65599, a prime near 2**16
that is efficiently expressible as (x << 6) + (x << 16) - x.   This
replaces a multiply with fast adds and shifts (with the two shifts
potentially being executed in parallel).  

Googling for "hash 65599" shows a long history of widespread use and
testing without any problems.

Raymond Hettinger

More information about the Python-Dev mailing list