STINNER Victor <vstin...@python.org> added the comment:

> It may be time to start emitting a warning if a Random subclass overrides 
> random() but not getrandbits() or vice versa.

Does someone know if there are users outside the stdlib of random subclass 
which only implements random()? I guess that a deprecation warning should help 
us to know :-)

There is also an implementation detail: technically, it's also sems to possible 
to only implement _randbelow(): see __init_subclass__(). But I'm not sure what 
happens in Python 3.8 if you implement _randbelow() but not random() not 
getrandbits().

In my experience, all RNG either generates random bits or random bytes, but not 
directly random floats. Usually, floats are computed from the other operations: 
that's what I'm proposing in BaseRandom. random() is now computed from 
getrandbits(). But it remains possible to override random(), as done in 
random.Random.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40346>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to