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 Missing fast path in PYLONG_FROM_UINT macro for compact integers #129168

Merged
merged 21 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ed9be47
Add Missing fast path in PyLong_From*() functions for compact integers
srinivasreddy Jan 22, 2025
ba70518
Revert change
srinivasreddy Jan 22, 2025
34315cb
Correct types
srinivasreddy Jan 22, 2025
0ef383c
Convert PyLong_FromLongLong() as well to leverage macro PYLONG_FROM_S…
srinivasreddy Jan 22, 2025
c00ba8c
Update Misc/NEWS.d/next/Core_and_Builtins/2025-01-22-14-24-44.gh-issu…
srinivasreddy Jan 22, 2025
2b5163f
Update Misc/NEWS.d/next/Core_and_Builtins/2025-01-22-14-24-44.gh-issu…
srinivasreddy Jan 22, 2025
955bb37
Update Misc/NEWS.d/next/Core_and_Builtins/2025-01-22-14-24-44.gh-issu…
skirpichev Jan 22, 2025
237b8b9
Update Objects/longobject.c
srinivasreddy Jan 22, 2025
11ad06f
Move back PYLONG_FROM_UINT where it belongs earlier
srinivasreddy Jan 22, 2025
c25b910
Undo the changes
srinivasreddy Jan 22, 2025
37a5c9a
Updated blurb accordingly
srinivasreddy Jan 22, 2025
2cb1aec
Remove :c:macro since it is only internal macro
srinivasreddy Jan 22, 2025
99c5420
Address review comments
srinivasreddy Jan 22, 2025
2724758
Revert the refactoring
srinivasreddy Jan 23, 2025
2a8692d
Revert changes
srinivasreddy Jan 23, 2025
70d85f1
update the blurb : Remove note about refactoring
srinivasreddy Jan 23, 2025
af410e0
Remove blurb
srinivasreddy Jan 23, 2025
5a9e201
Revert "Remove blurb"
srinivasreddy Jan 23, 2025
5760c95
Update news entry for better wording
srinivasreddy Jan 23, 2025
1f81b87
Update Misc/NEWS.d/next/Core_and_Builtins/2025-01-22-14-24-44.gh-issu…
srinivasreddy Jan 23, 2025
f4d74d2
Update Misc/NEWS.d/next/Core_and_Builtins/2025-01-22-14-24-44.gh-issu…
srinivasreddy Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add fast path for medium-size integers in :c:func:`PyLong_FromUnsignedLong`,
:c:func:`PyLong_FromUnsignedLongLong` and :c:func:`PyLong_FromSize_t`.
8 changes: 6 additions & 2 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,13 @@ PyLong_FromLong(long ival)
if (IS_SMALL_UINT(ival)) { \
return get_small_int((sdigit)(ival)); \
} \
if ((ival) <= PyLong_MASK) { \
return _PyLong_FromMedium((sdigit)(ival)); \
} \
skirpichev marked this conversation as resolved.
Show resolved Hide resolved
/* Do shift in two steps to avoid possible undefined behavior. */ \
INT_TYPE t = (ival) >> PyLong_SHIFT >> PyLong_SHIFT; \
/* Count the number of Python digits. */ \
Py_ssize_t ndigits = 0; \
INT_TYPE t = (ival); \
Py_ssize_t ndigits = 2; \
while (t) { \
++ndigits; \
t >>= PyLong_SHIFT; \
Expand Down
Loading