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 rhettinger
Recipients Mathis Hammel, mark.dickinson, rhettinger, tim.peters
Date 2019-05-23.15:22:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
> it's a bit surprising all on its own that `getrandbits(0)` 
> raises an exception.

Given that there would be no randomness in the result, it makes sense to me that getrandbits(0) is documented to raise an exception.

Related:
    `randrange(0)` raises an exception
    `choice([])` raises an exception


> In any case, I'd leave _randbelow_with_getrandbits alone.

That makes sense to me as well. I'll mark this as closed.

There's one other bright side.  If someone really cares about the speed of the power-of-two case, they can already call `getrandbits(10)` instead of `randrange(1024)`.  The former is about 7x faster.

Mathis, thank you for taking the time to look at this code.
History
Date User Action Args
2019-05-23 15:22:36rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, Mathis Hammel
2019-05-23 15:22:36rhettingersetmessageid: <[email protected]>
2019-05-23 15:22:36rhettingerlinkissue37000 messages
2019-05-23 15:22:36rhettingercreate