[issue27706] Random.seed, whose purpose is purportedly determinism, behaves non-deterministically with strings due to hash randomization

Raymond Hettinger report at bugs.python.org
Sun Aug 7 21:37:51 EDT 2016


Raymond Hettinger added the comment:

Thanks for the bug report.  This is a case of something that used to work fine but was affected by an incidental change elsewhere.   

To support the use case for deterministic sequences of values starting from a known point, the docs promise, "If a new seeding method is added, then a backward compatible seeder will be offered. The generator’s random() method will continue to produce the same sequence when the compatible seeder is given the same seed." (See https://docs.python.org/3/library/random.html#notes-on-reproducibility )

The resolution is to have the random module (line 327 in Modules/_randommodule.c) use a new _PyObject_Hash() function that deterministically matches what the old PyObject_Hash() function used to do.

Marking this as "needs patch" and saving it for Nofar Schnider to work on (she's an aspiring core dev).

----------
stage:  -> needs patch
versions: +Python 2.7, Python 3.5, Python 3.6

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


More information about the Python-bugs-list mailing list