[Python-ideas] Globally configurable random number generation)
Terry Reedy
tjreedy at udel.edu
Tue Sep 15 00:31:24 CEST 2015
On 9/14/2015 11:04 AM, Serhiy Storchaka wrote:
> On 14.09.15 16:32, Nick Coghlan wrote:
>> * make random.Random a subclass of SeedableRandom that deprecates
>> seed(), getstate() and setstate()
An alternate proposal is to initialize the module so that random uses a
something more 'secure' than MT. Then...
> I would make seed() and setstate() to switch to seedable algorithm.
In particular, to MT. Also switch on a getstate() call.
> If you don't use seed() or setstate(), it is not important that the
> algorithm is changed. If you use seed() or setstate(), you expect
> reproducible behavior.
There is more than one possible internal implementation. But for any of
them, the change should be invisible to callers. (Representations and
introspection results would be a different matter.)
I understand that the docs currently say that random uses MT. But I
wonder if any version of the above could be used in current versions, so
as to immediately "upgrade a lot of existing instructions on the
internet" and code that follows such instructions.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list