]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-129149: Add fast path for medium-sized integers in `PyLong_FromSsize_t()` (#129301)
authorChris Eibl <138194463+chris-eibl@users.noreply.github.com>
Thu, 13 Mar 2025 11:06:56 +0000 (12:06 +0100)
committerGitHub <noreply@github.com>
Thu, 13 Mar 2025 11:06:56 +0000 (12:06 +0100)
commit119bcfad9cac9ac8fa5fa6c0f3ee3ccfca778fe1
treed25bb2858047ec253ad6f71b67de236bdaec9a90
parenta005835f699b5ba44beb8c856db1f62454522e1e
gh-129149: Add fast path for medium-sized integers in `PyLong_FromSsize_t()` (#129301)

The implementation of `PyLong_FromLong()`, `PyLong_FromLongLong()` and `PyLong_FromSsize_t()`
are now handled by a common macro `PYLONG_FROM_INT` which contains fast paths depending on the
size of the integer to convert. Consequently, `PyLong_FromSsize_t()` for medium-sized integers is faster
by roughly 25%.

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Lib/test/test_capi/test_long.py
Misc/NEWS.d/next/Core_and_Builtins/2025-01-25-20-07-03.gh-issue-129149.njeFJi.rst [new file with mode: 0644]
Objects/longobject.c