gh-127119: Faster check for small ints in long_dealloc (GH-127620)

This commit is contained in:
Pieter Eendebak 2025-01-29 16:22:18 +01:00 committed by GitHub
parent 3a974e39d5
commit a29221675e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 45 deletions

View file

@ -890,7 +890,7 @@ class PyLongObjectPtr(PyObjectPtr):
def proxyval(self, visited):
'''
Python's Include/longinterpr.h has this declaration:
Python's Include/cpython/longinterpr.h has this declaration:
typedef struct _PyLongValue {
uintptr_t lv_tag; /* Number of digits, sign and flags */
@ -909,8 +909,7 @@ class PyLongObjectPtr(PyObjectPtr):
- 0: Positive
- 1: Zero
- 2: Negative
The third lowest bit of lv_tag is reserved for an immortality flag, but is
not currently used.
The third lowest bit of lv_tag is set to 1 for the small ints and 0 otherwise.
where SHIFT can be either:
#define PyLong_SHIFT 30