In Python 2 documentation of the random.seed()
function I found a warning:
If a hashable object is given, deterministic results are only assured when PYTHONHASHSEED is disabled.
From https://docs.python.org/2/using/cmdline.html#envvar-PYTHONHASHSEED I infer that the -R
switch of the interpreter may have similar effect as PYTHONHASHSEED
.
I have verified empirically, that random numbers seeded with small integers seems to be reproducible. So do hashes of small integers.
However, int
is hashable. Is it stated explicitly in any trusted source, that it is safe to use it as a seed for a reproducible sequence of random numbers?
In contrast to Reproducibility of python pseudo-random numbers across systems and versions?, reproducibility within same system and interpreter is enough.
The documentation confirms its safety in Python 2.6:
(from https://docs.python.org/2.6/library/random.html#random.seed)
[EDIT]
The documentation for 2.7 has been updated to: