GeezerVison is showing github.com — gh-100239: use PyFloat_AS_DOUBLE and _PyLong_IsZero in the float / compactlong specializations by chris-eibl · Pull Request #144826 · python/cpython
Conversation
chris-eibl
commented
Feb 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Since we know that we deal with exact floats here.
This is just a small follow-up on #128722 and #128963.
I don't think it deserves a news entry, but I'd happily create it if deemed meaningful enough.
Microbenchmark from @iritkatriel 's PR:
Old:
>>> timeit("for i in range(10000):\n\tb = a+i", number=100000, setup="a = 1.0")
42.05178890001844
>>> timeit("for i in range(10000):\n\tb = i+a", number=100000, setup="a = 1.0")
41.31541720000678
New:
>>> timeit("for i in range(10000):\n\tb = a+i", number=100000, setup="a = 1.0")
38.316913699993165
>>> timeit("for i in range(10000):\n\tb = i+a", number=100000, setup="a = 1.0")
38.37592560000485
Fastmark results are within the noise 1, the three arithmetic benchmarks @Fidget-Spinner mentioned are a tad faster:

Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
know that we deal with exact floats here
|
This microbenchmark
import time
def bench():
t = time.perf_counter()
f = 1.0
for i in range(60000):
for j in range(1, 1000):
f = f + j
f = f - j
f = f / j
f = f * j
print(time.perf_counter() - t)
if __name__ == "__main__":
bench()
shows even better speedup:
old: 6.5 seconds
new: 5.5 seconds
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I don't think it deserves a news entry, but I'd happily create it if deemed meaningful enough.
This is user-visible change. So, I believe it deserves a news entry.
|
chris-eibl reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
@@ -0,0 +1,2 @@ |
|
|
Speedup ``BINARY_OP_EXTEND`` for exact floats and medium-size integers by up
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compact ints are an implementation detail and the term medium-size integers has been chosen in news entries in the past for them.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chris-eibl reacted with heart emoji
Uh oh!
There was an error while loading. Please reload this page.
ljfp
pushed a commit
to ljfp/cpython
that referenced
this pull request
Apr 25, 2026
Reviewers
Eclips4
Eclips4 approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|