bpo-46311: Clean up PyLong_FromLong and PyLong_FromLongLong#30496
bpo-46311: Clean up PyLong_FromLong and PyLong_FromLongLong#30496markshannon merged 3 commits intopython:mainfrom
Conversation
|
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. |
|
@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.
|
Thanks. Looks good on initial review. |
mdickinson
left a comment
There was a problem hiding this comment.
Two changes that should silence compiler warnings.
|
Thanks, @markshannon. The compiler warnings have been silenced. |
|
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