[New-bugs-announce] [issue46407] optimizing `1 << n` or `2 ** n` and modulo-only operations

theeshallnotknowethme report at bugs.python.org
Mon Jan 17 01:46:43 EST 2022


New submission from theeshallnotknowethme <nohackingofkrowten at gmail.com>:

Optimize calculating powers of 2 for integers. Does not include optimizing modular exponentiation because benchmarking shows current version of modular exponentiation is faster. Also optimizes any call with the structure `l_divmod(a, b, NULL, &mod)`.

> python_modified.exe -m timeit -s "x = 2" "x**10000000"
10000 loops, best of 5: 33.1 usec per loop
> python_current.exe -m timeit -s "x = 2" "x**10000000"
10 loops, best of 5: 35.2 msec per loop

----------
components: Interpreter Core
messages: 410744
nosy: February291948
priority: normal
severity: normal
status: open
title: optimizing `1 << n` or `2 ** n` and modulo-only operations
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46407>
_______________________________________


More information about the New-bugs-announce mailing list