]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-118610: Centralize power caching in `_pylong.py` (#118611)
authorTim Peters <tim.peters@gmail.com>
Wed, 8 May 2024 00:09:09 +0000 (19:09 -0500)
committerGitHub <noreply@github.com>
Wed, 8 May 2024 00:09:09 +0000 (19:09 -0500)
commit2f0a338be66e276a700f86af51d5ef54a138cbfb
tree3cf16245a701df9250c93b7684dbee8bc44b8376
parent2a85bed89dc14327afe344a57233a37795fde2b9
gh-118610: Centralize power caching in `_pylong.py` (#118611)

A new `compute_powers()` function computes all and only the powers of the base the various base-conversion functions need, as efficiently as reasonably possible (turns out that invoking `**`is needed at most once). This typically gives a few % speedup, but the primary point is to simplify the base-conversion functions, which no longer need their own, ad hoc, and less efficient power-caching schemes.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/_pylong.py
Lib/test/test_int.py