on the prng behind random.random()

Chris Angelico rosuav at gmail.com
Mon Nov 19 15:38:01 EST 2018


On Tue, Nov 20, 2018 at 7:31 AM Robert Girault <r at dev.null> wrote:
> Nice.  So Python's random.random() does indeed use mt19937.  Since it's
> been broken for years, why isn't it replaced by something newer like
> ChaCha20?  Is it due to backward compatibility?  That would make sense.

What exactly do you mean by "broken"? If you're generating random
numbers for any sort of security purpose, you probably should look at
this:

https://docs.python.org/3/library/secrets.html

(New in 3.6, though, hence the "probably". If you need to support 3.5
or older - including 2.7 - then you can't use that.)

ChrisA



More information about the Python-list mailing list