Message343302
> 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. |
|
| Date |
User |
Action |
Args |
| 2019-05-23 15:22:36 | rhettinger | set | recipients:
+ rhettinger, tim.peters, mark.dickinson, Mathis Hammel |
| 2019-05-23 15:22:36 | rhettinger | set | messageid: <[email protected]> |
| 2019-05-23 15:22:36 | rhettinger | link | issue37000 messages |
| 2019-05-23 15:22:36 | rhettinger | create | |
|