Hashing Function

jepler at unpythonic.net jepler at unpythonic.net
Thu Nov 17 23:34:38 CET 2005


As Fredrik suggests, consult the source to find out.  Almost all of this
is in the realm of being an implementation detail, and hashes aren't
guaranteed to be the same from version to version or machine to machine.
I'm not even sure they're guaranteed to be the same from run to run.

Here's an example:

On a 32-bit linux machine running python 2.3:
$ python -c 'print hash("a" * 1000)'
-884397280

On a 64-bit linux machine running python 2.4:
$ python -c 'print hash("a" * 1000)'
2513399373082733344

A little more research suggests that, at least for strings, the hashing
algrithm is unchanged from 1.5.2 to 2.4, but is dependant on the range of a
platform 'long'.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051117/e64c13be/attachment.pgp>


More information about the Python-list mailing list