This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients mark.dickinson, pitrou, rhettinger, serhiy.storchaka, tim.peters, vstinner
Date 2020-04-21.15:40:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587483631.7.0.924983920129.issue40346@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2020-04-21 15:40:31vstinnersetrecipients: + vstinner, tim.peters, rhettinger, mark.dickinson, pitrou, serhiy.storchaka
2020-04-21 15:40:31vstinnersetmessageid: <1587483631.7.0.924983920129.issue40346@roundup.psfhosted.org>
2020-04-21 15:40:31vstinnerlinkissue40346 messages
2020-04-21 15:40:31vstinnercreate