Uh oh!
There was an error while loading. Please reload this page.
bpo-46311: Clean up PyLong_FromLong and PyLong_FromLongLong - #30496
Conversation
erlend-aasland
commented
Jan 9, 2022
I don't see how this qualifies for skip issue. Perhaps I am misreading the devguide, but to me this PR seems inappropriately labelled. If I am mistaken; sorry for the noise. |
mdickinson
commented
Jan 9, 2022
@erlend-aasland Yes, I think you're right. I'll add an issue. |
| } | ||
| /* Create a new int object from a C long int */ | ||
There was a problem hiding this comment.
This is a minor consistency fix, following the Boy Scout Rule: the prevailing style in this file is to leave a blank line between the comment-description and the definition. But the change is not strictly necessary for this PR, and I can revert if reviewers prefer.
markshannon
commented
Jan 21, 2022
Thanks. Looks good on initial review. |
mdickinson
left a comment
There was a problem hiding this comment.
Two changes that should silence compiler warnings.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mdickinson
commented
Jan 22, 2022
Thanks, @markshannon. The compiler warnings have been silenced. |
markshannon
commented
Mar 1, 2022
Thanks |
PR #27832 inadvertently introduced a couple of changes to
PyLong_FromLongthat didn't make a lot of sense: an(unsigned long)cast was replaced with(twodigits), and a digit count variable (counting number of PyLong digits in a C long) had its type needlessly changed frominttoPy_ssize_t.(unsigned long)cast is obviously correct, while figuring out whether(twodigits)loses information takes some work.long.This PR:
ival < 0 ? 0U-(unsigned long)ival : ival) gets compiled to something branchless on most platforms, as doesival < 0 ? -ndigits : ndigitsPyLong_FromLongLong, which now has a fast path for medium-size values.https://bugs.python.org/issue46311