[issue44376] Improve performance of integer exponentiation

2021-06-12 Thread Tim Peters
Tim Peters added the comment: Closing this now because the pull request did, I believe, all that can be done at the function level. Exponents of 1 and 2 are well within a factor of 2 of repeated multiplication now, and it's essentially a tie at exponent 3 now. Above that, pow() wins now. On

[issue44376] Improve performance of integer exponentiation

2021-06-12 Thread Tim Peters
Tim Peters added the comment: New changeset 9d8dd8f08aae4ad6e73a9322a4e9dee965afebbc by Tim Peters in branch 'main': bpo-44376 - reduce pow() overhead for small exponents (GH-26662) https://github.com/python/cpython/commit/9d8dd8f08aae4ad6e73a9322a4e9dee965afebbc -- ___

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Tim Peters
Tim Peters added the comment: This is a stab at reducing overhead for small exponents, along the lines I sketched: https://github.com/python/cpython/pull/26662 Unfortunately, I've been unable to convince BPO and GitHub to recognize that the PR is related to this report. Did something basic

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Tim Peters
Change by Tim Peters : -- keywords: +patch pull_requests: +25248 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26662 ___ Python tracker ___ _

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Tim Peters
Tim Peters added the comment: Under the released 3.9.5 for 64-bit Win10, raising to the power 2 is clearly much slower than multiplying directly: C:\Windows\System32>py -3 -m timeit -s "x=151" "x*x" 1000 loops, best of 5: 30 nsec per loop C:\Windows\System32>py -3 -m timeit -s "x=151" "x

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Mark Dickinson
Mark Dickinson added the comment: I can't reproduce this on my Mac laptop (using Python builds from MacPorts). Numbers for both x**2 and x*x are fairly stable across Python 3.2 to Python 3.10. There's some variation, but nothing close to the same extent that Steven is seeing. Here are my ra

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Is it because exponentiation becomes slower or because multiplication becomes faster? What are absolute numbers? -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44376] Improve performance of integer exponentiation

2021-06-10 Thread Steven D'Aprano
New submission from Steven D'Aprano : Naively, I assumed that `x**2` would be faster than `x*x` as there is only one name lookup in the first, and two in the second. But it is slower. The performance of `x**2` relative to `x*x` has gradually deteriorated compared to `x*x` over many versions.