'How do I determine what PRNG python.random is using?
I'm looking for more information about random. Primarily what was the seed and how many steps have happened in that pseudo random sequence & Was that seed a datetime, i.e. did random use the system provided random or default to time?
I looked at dir(random) and didn't see anything super promising...
Solution 1:[1]
The documentation states:
Almost all module functions depend on the basic function random(), which generates a random float uniformly in the semi-open range [0.0, 1.0). Python uses the Mersenne Twister as the core generator. It produces 53-bit precision floats and has a period of 2**19937-1. The underlying implementation in C is both fast and threadsafe. The Mersenne Twister is one of the most extensively tested random number generators in existence. However, being completely deterministic, it is not suitable for all purposes, and is completely unsuitable for cryptographic purposes.
You can study the source code here, in particular the default implementation "seeds from current time or from an operating system specific randomness source if available"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Waterworth |
