Message366923
> 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. |
|
Date |
User |
Action |
Args |
2020-04-21 15:40:31 | vstinner | set | recipients:
+ vstinner, tim.peters, rhettinger, mark.dickinson, pitrou, serhiy.storchaka |
2020-04-21 15:40:31 | vstinner | set | messageid: <1587483631.7.0.924983920129.issue40346@roundup.psfhosted.org> |
2020-04-21 15:40:31 | vstinner | link | issue40346 messages |
2020-04-21 15:40:31 | vstinner | create | |
|