Title: random.seed version=1 behavior
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.6
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 2017-02-06 07:46 by rhettinger. 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)

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

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()))"
$ python3.5 -c "from random import *; seed(1); print(repr(random()))"

The reproducibility guarantee is limited to the seeder and the output of random().  The downstream algorithms are allowed to change.  See
Date User Action Args
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