New submission from Donovan Baarda <a...@minkirri.apana.org.au>:
I encountered a very significant slowdown migrating some code from python2.7 to python3.9 that I tracked down to randrange() being slow. After digging I noticed that _randbelow_with_getrandbits() calls getrandbits() 2x as many times, and asks for one more bit each time, than is actually required if the range requested is a power of 2. I have a GitHub PR on the way to fix this... ---------- components: Library (Lib) messages: 385769 nosy: abo priority: normal severity: normal status: open title: random.py randrange() is very slow if the range is a power of 2. type: performance versions: Python 3.10, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43040> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com