Home » Category » Python

Python: hash() yields different results for different platforms

200| Wed, 07 May 2008 20:29:00 GMT| tim_peters| Comments (0)
[Grant Edwards]

[Qiangning Hong]
> Is this relationship (same low 32 bits) guaranteed?


No. Nothing about hashes is guaranteed, except that when x and y are
of a hashable type, and x == y, then hash(x) == hash(y) too.

> Will it change in the future version?


That's possible, but not planned. Note that the guts of string
hashing in CPython today is implemented via

while (--len >= 0)
x = (1000003*x) ^ *p++;

where x is C type "long", and the C language doesn't even define what
that does (behavior when signed multiplication overflows isn't defined
in C).

Keywords & Tags: hash, yields, different, results, platforms, python

URL: http://programming.itags.org/python/32377/
 
«« Prev - Next »» 0 helpful answers below.

Python Hot Answers

Python New questions

Python Related Categories