This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: random.seed version=1 behavior
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Maciej Obarski, mark.dickinson, rhettinger, vstinner
Priority: normal Keywords:

Created on 2017-02-06 07:27 by Maciej Obarski, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg287089 - (view) Author: Maciej Obarski (Maciej Obarski) Date: 2017-02-06 07:27
random.seed version=1 wont generate the same randint sequences in python2 and python3

Python 2.7:
>>> seed(1); randint(0,100)
13

Python 3.6:
>>> seed(1,version=1); randint(0,100)
17

The documentation states that versio=1 is "provided for reproducing random sequences from older versions of Python" and "If a new seeding method is added, then a backward compatible seeder will be offered."
msg287094 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-02-06 07:46
Sorry Marciej, this isn't a bug.  The seeders are consistent. It is the code for randint() that has changed (to fix a minor imbalance in the distribution).  

$ python2.7 -c "from random import *; seed(1); print(repr(random()))"
0.13436424411240122
$ python3.5 -c "from random import *; seed(1); print(repr(random()))"
0.13436424411240122

The reproducibility guarantee is limited to the seeder and the output of random().  The downstream algorithms are allowed to change.  See
https://docs.python.org/3/library/random.html#notes-on-reproducibility
History
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73644
2017-02-06 07:46:52rhettingersetstatus: open -> closed
resolution: not a bug
messages: + msg287094

stage: resolved
2017-02-06 07:36:49rhettingersetassignee: rhettinger
2017-02-06 07:32:28xiang.zhangsetnosy: + rhettinger, mark.dickinson, vstinner
2017-02-06 07:27:36Maciej Obarskicreate