Reproducibility of python pseudo-random numbers across systems and versions?

后端 未结 5 689
后悔当初
后悔当初 2020-12-20 12:08

I need to generate a controlled sequence of pseudo-random numbers, given an initial parameter. For that I\'m using the standard python random generator, seeded by this param

5条回答
  •  囚心锁ツ
    2020-12-20 12:22

    I just found out that there is also a difference between python3.7 and python3.8.

    The following code behaves the same

    from random import Random
    seed = 317
    rand = Random(seed)
    rand.getrandbits(64)
    

    but if you use from _random import Random instead, it behaves differently.

提交回复
热议问题