Why is seeding the random generator not stable between versions of Python?

后端 未结 2 1827
盖世英雄少女心
盖世英雄少女心 2020-12-16 10:40

I am trying to reproduce a random sequence from python\'s random.random() on a different system with a different python3 version installed.

This should

2条回答
  •  春和景丽
    2020-12-16 11:26

    I was looking through What's New in Python 3.2 (because of this question), and I found:

    The random.seed() function and method now salt string seeds with an sha512 hash function. To access the previous version of seed in order to reproduce Python 3.1 sequences, set the version argument to 1, random.seed(s, version=1).

    It appears to be a breaking change (from 3.1 to 3.2) with a backwards compatibility option.

    (As borrible pointed out, because a compatible seeder is offered the documentation contract has not been violated.)

提交回复
热议问题