hash() algorithm

Kristofer Pettijohn kristofer at cybernetik.net
Wed Jul 21 22:24:24 CEST 2004


Beno?t Dejean <bnet at ifrance.com> wrote:
> hi. Is the hash() algorithm standard ? Does hash(some_string) will always
> return the same hash code on every arch ?
> 
> i need to use a ~checksum function, like md5, but i was also thinking
> about hash() which is obviously simpler. So i can safely rely on hash()
> behaviour so i can use it to generate ~strong and portable
> identifier/checksum ?

I'm not an expert, but I believe so.  I just tried three machines:

OS X 10.4: (Python 2.3)
>>> hash('test')
1308370872

Solaris: (Python 1.6)
>>> hash('test')
1308370872

FreeBSD 5.2.1: (Python 2.3)
>>> hash('test')
1308370872

> 
> thank you

-- 
Kristofer Pettijohn
kristofer at cybernetik.net



More information about the Python-list mailing list