Lib/random.py
cpython 3.14 @ ab2d84fe1023/Lib/random.py
All user-visible random-number methods live here. The seeding and
raw 53-bit integer generation are delegated to _random.Random, the C
Mersenne Twister (MT19937) implementation. Lib/random.py wraps that
type in a Python Random class and adds every higher-level algorithm:
range selection, sequence operations, population sampling, and several
real-valued distributions.
SystemRandom is a subclass that overrides the generator primitives
with os.urandom so the MT state is never used. It cannot be seeded
or pickled.
A module-level Random instance is created at import time and its
bound methods (random, seed, randrange, randint, choice,
choices, shuffle, sample, gauss, etc.) are exported as
module-level functions.