[Python-ideas] Python's Source of Randomness and the random.py module Redux

Nick Coghlan ncoghlan at gmail.com
Thu Sep 10 19:27:50 CEST 2015

On 11 September 2015 at 03:11, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, Sep 11, 2015 at 3:00 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> As far as the proposed Seeded/Seedless naming goes, that deliberately
>> glosses over the fact that "seed" gets used to refer to two different
>> things - seeding a PRNG with entropy, and seeding a deterministic PRNG
>> with a particular seed value. The key is that "SeedlessRandom" won't
>> have a "seed()" *method*, and that's the single most salient fact
>> about it from a user experience perspective: you can't get the same
>> output by providing the same seed value, because we wouldn't let you
>> provide a seed value at all.
> Aside from sounding like varieties of grapes in a grocery, those names
> seem just fine. From the POV of someone with a bit of comprehension of
> crypto (as in, "use /dev/urandom rather than a PRNG", but not enough
> knowledge to actually build or verify these things), the distinction
> is precise: with SeededRandom, I can give it a seed and get back a
> predictable sequence of numbers, but with SeedlessRandom, I can't. I'm
> not sure what the difference is between "seeding a PRNG with entropy"
> and "seeding a deterministic PRNG with a particular seed value",
> though; aside from the fact that one of them uses a known value and
> the other doesn't, of course.

Actually, that was just a mistake on my part - they're really the same
thing, and the only distinction is the one you mention: setting the
seed to a known value. Thus the main seed-related difference between
something like arc4random and other random APIs is the same one I'm
proposing to make here: it's seedless at the API level because it
takes care of collecting its own initial entropy from the operating
system's random number API.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list