Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-129149: Add fast path for medium-size integers in PyLong_FromSsize_t() #129301

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

chris-eibl
Copy link
Contributor

@chris-eibl chris-eibl commented Jan 25, 2025

Add the macro PYLONG_FROM_INT and use it in PyLong_FromLong() and PyLong_FromLongLong().
There, this is just a binary compatible refactoring.

Use it in PyLong_FromSsize_t(), too, to get the fast path for medium-size integers.

Use it in PyLong_FromLong() and PyLong_FromLongLong().
This is just a refactoring and will create the same binary code.
Use it in now in PyLong_FromSsize_t(), too.
@chris-eibl chris-eibl changed the title gh-129149: Add fast path for medium-size integers in :c:func:PyLong_FromSsize_t gh-129149: Add fast path for medium-size integers in PyLong_FromSsize_t() Jan 25, 2025
Copy link
Member

@skirpichev skirpichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Few stylistic nitpicks, feel free to ignore.

Objects/longobject.c Outdated Show resolved Hide resolved
Objects/longobject.c Outdated Show resolved Hide resolved
Objects/longobject.c Outdated Show resolved Hide resolved
chris-eibl and others added 3 commits January 26, 2025 06:22
Co-authored-by: Sergey B Kirpichev <[email protected]>
Co-authored-by: Sergey B Kirpichev <[email protected]>
Co-authored-by: Sergey B Kirpichev <[email protected]>
@chris-eibl
Copy link
Contributor Author

I like your suggestions, brings us more in sync with PYLONG_FROM_UINT.
Just wanted to keep the diff small.

@skirpichev
Copy link
Member

BTW, next time you can apply several suggestions in one shot (subscribers will get less notifications): it's possible add them in one batch (on tab "files changed").

@skirpichev skirpichev self-requested a review January 26, 2025 05:43
@chris-eibl
Copy link
Contributor Author

chris-eibl commented Jan 26, 2025

BTW, next time you can apply several suggestions in one shot (subscribers will get less notifications): it's possible add them in one batch (on tab "files changed").

Great, will do!

I've done some more syncs with PYLONG_FROM_UINT, if we want to keep the diff small, we can remove (all of) them.

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.

2 participants