GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@chris-eibl chris-eibl commented Feb 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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:

diff

  • Issue: Specialize long tail of binary operations using a table. #100239

Footnotes

  1. see my gist how I do them ↩

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chris-eibl
use PyFloat_AS_DOUBLE and _PyLong_IsZero since we
075c2a8
know that we deal with exact floats here
@bedevere-app bedevere-app Bot added the awaiting review label Feb 14, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 14, 2026
Specialize long tail of binary operations using a table. #100239
Open
@chris-eibl chris-eibl added the skip news label Feb 14, 2026
@chris-eibl
chris-eibl requested a review from iritkatriel February 14, 2026 20:02
@chris-eibl

chris-eibl commented Feb 14, 2026

Copy link
Copy Markdown
Member Author

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chris-eibl
chris-eibl requested a review from Eclips4 February 14, 2026 20:21
skirpichev
skirpichev approved these changes Feb 15, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Feb 15, 2026
@skirpichev

skirpichev commented Feb 15, 2026

Copy link
Copy Markdown
Member

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chris-eibl added 2 commits February 17, 2026 20:55
@chris-eibl
Merge branch 'main' into float_exact
27d1858
@chris-eibl
add news
bcfbadb
chris-eibl
chris-eibl commented Feb 17, 2026
View reviewed changes
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-02-17-21-04-03.gh-issue-100239.LyVabQ.rst
@@ -0,0 +1,2 @@
Speedup ``BINARY_OP_EXTEND`` for exact floats and medium-size integers by up

@chris-eibl chris-eibl Feb 17, 2026

Copy link
Copy Markdown
Member Author

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.

All reactions
@chris-eibl chris-eibl removed the skip news label Feb 17, 2026
Eclips4
Eclips4 approved these changes Feb 19, 2026
View reviewed changes

@Eclips4 Eclips4 left a comment

Copy link
Copy Markdown
Member

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.

Thank you Chris!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chris-eibl reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 19, 2026
@Eclips4
Eclips4 merged commit b5c8e6e into python:main Feb 19, 2026
53 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 19, 2026
@chris-eibl
chris-eibl deleted the float_exact branch February 19, 2026 19:59
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
@chris-eibl @brijkapadia
pythongh-100239: Use PyFloat_AS_DOUBLE and _PyLong_IsZero` in t…
c155613
…he float / compactlong specializations (python#144826)
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@chris-eibl @ljfp
pythongh-100239: Use PyFloat_AS_DOUBLE and _PyLong_IsZero` in t…
c33f46d
…he float / compactlong specializations (python#144826)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@skirpichev skirpichev skirpichev approved these changes
@Eclips4 Eclips4 Eclips4 approved these changes
@iritkatriel iritkatriel Awaiting requested review from iritkatriel

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@chris-eibl @skirpichev @Eclips4
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.