ruben_KAI
ruben_KAI

Reputation: 325

How does Python generate random numbers?

I understand that I should use os.urandom() or SystemRandom in Python for 'secure' pseudo-random numbers.

But how does Python generate these random numbers logically?

Also is there a way to generate a number in Python that is 'more random' than others?

Upvotes: 8

Views: 5353

Answers (1)

Wyzard
Wyzard

Reputation: 34563

For "secure" random numbers, Python doesn't actually generate them: it gets them from the operating system, which has a special driver that gathers entropy from various real-world sources, such as variations in timing between keystrokes and disk seeks.

Upvotes: 7

Related Questions