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 abo
Recipients abo, mark.dickinson, rhettinger
Date 2021-01-27.23:24:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
I had a look at the C implementation of getrandbits() and spotted this;

https://github.com/python/cpython/blob/64fc105b2d2faaeadd1026d2417b83915af6622f/Modules/_randommodule.c#L487

In my case I was also being hit by randrange(2**32) calling getrandbits(33) just pushing it past using the optimized fast-path for ranges needing <=32 bits. So not only was it calling getrandbits() 2x as many times as necessary, under the hood it was generating 64 random bits each time using a slow path.
History
Date User Action Args
2021-01-27 23:24:41abosetrecipients: + abo, rhettinger, mark.dickinson
2021-01-27 23:24:41abosetmessageid: <[email protected]>
2021-01-27 23:24:41abolinkissue43040 messages
2021-01-27 23:24:41abocreate