[issue7889] random produces different output on different architectures

Antoine Pitrou report at bugs.python.org
Tue Feb 9 12:43:50 CET 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

Well, ideally we should drop the automatic hash() and only accept:
1) ints/longs
2) buffer-like objects

(and tell people to hash() explicitly if they want to)

If that's too disruptive, we should document it.
And, for 3.x, provide the following recipe to hash from a bytes object without losing entropy, and keeping the same results under 32-bit and 64-bit builds:

>>> import random
>>> random.seed(int.from_bytes(b'foo', 'little'))
>>> random.random()
0.08384169414918807

----------
versions: +Python 2.6, Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7889>
_______________________________________


More information about the Python-bugs-list mailing list