◐ Shell
reader mode source ↗
Skip to content

bpo-42161: mathmodule.c: move _PyLong_GetOne() loop invariant#26391

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:math_micro_optim
May 26, 2021
Merged

bpo-42161: mathmodule.c: move _PyLong_GetOne() loop invariant#26391
vstinner merged 1 commit into
python:mainfrom
vstinner:math_micro_optim

Conversation

@vstinner

@vstinner vstinner commented May 26, 2021

Copy link
Copy Markdown
Member

Move _PyLong_GetZero() and _PyLong_GetOne() loop invariants outside
loops in functions:

  • math.comb()
  • math.gcd()
  • math.lcm()
  • math.perm()

https://bugs.python.org/issue42161

Move _PyLong_GetZero() and _PyLong_GetOne() loop invariants outside
loops in functions:

* math.comb()
* math.gcd()
* math.lcm()
* math.perm()
@vstinner

Copy link
Copy Markdown
Member Author

This change should be backport to 3.10 since it fix a minor performance regression introduced in Python 3.10: https://bugs.python.org/issue42161#msg388988

@vstinner

Copy link
Copy Markdown
Member Author

@vstinner

Copy link
Copy Markdown
Member Author

I didn't notice that _PyLong_GetZero() and _PyLong_GetOne() were used in loops in Modules/mathmodule.c when I wrote my commit 3783413 (I tried to pay attention to that, to avoid performance regression).

@vstinner vstinner merged commit 3e7ee02 into python:main May 26, 2021
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@vstinner vstinner deleted the math_micro_optim branch May 26, 2021 22:51
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2021
…GH-26391)

Move _PyLong_GetZero() and _PyLong_GetOne() loop invariants outside
loops in functions:

* math.comb()
* math.gcd()
* math.lcm()
* math.perm()
(cherry picked from commit 3e7ee02)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-bot

Copy link
Copy Markdown

GH-26393 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label May 26, 2021
@vstinner

Copy link
Copy Markdown
Member Author

Thanks for the review @erlend-aasland.

vstinner added a commit that referenced this pull request May 26, 2021
…) (GH-26393)

Move _PyLong_GetZero() and _PyLong_GetOne() loop invariants outside
loops in functions:

* math.comb()
* math.gcd()
* math.lcm()
* math.perm()
(cherry picked from commit 3e7ee02)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants