New submission from Mark Dickinson <dicki...@gmail.com>:
PR GH-27832 inadvertently (I believe) introduced a couple of changes to PyLong_FromLong that 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 from int to Py_ssize_t. The first change is a potential portability bug, but only on platforms where the width of C's `long` exceeds 64 bits. The (unsigned long) cast is obviously correct, while figuring out whether (twodigits) loses information takes some work. The second change is merely a potential pessimization: there's no need to use what's typically a 64-bit integer to count the number of PyLong digits in a long. While fixing these, I've also reworked the PyLong_FromLong code a bit to move the medium int check earlier, and I've applied analogous changes to PyLong_FromLongLong. ---------- messages: 410141 nosy: Mark.Shannon, mark.dickinson priority: normal severity: normal status: open title: Clean up PyLong_FromLong and PyLong_FromLongLong versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46311> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com