Raymond Hettinger <[email protected]> added the comment:
> 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.
----------
resolution: -> rejected
stage: patch review -> resolved
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37000>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com