Skip to content

Commit 45b3b04

Browse files
vstinnerskirpichev
andauthored
Rename to _PyLong_IsSmallInt()
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
1 parent 0b29e28 commit 45b3b04

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Include/internal/pycore_long.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ _PyLong_IsPositive(const PyLongObject *op)
234234

235235
/* Return true if the argument is a small int */
236236
static inline bool
237-
_PyLong_HasImmortalTag(const PyLongObject *op)
237+
_PyLong_IsSmallInt(const PyLongObject *op)
238238
{
239239
assert(PyLong_Check(op));
240240
bool is_small_int = (op->long_value.lv_tag & IMMORTALITY_BIT_MASK) != 0;
@@ -309,7 +309,7 @@ _PyLong_SetDigitCount(PyLongObject *op, Py_ssize_t size)
309309
static inline void
310310
_PyLong_FlipSign(PyLongObject *op)
311311
{
312-
assert(!_PyLong_HasImmortalTag(op));
312+
assert(!_PyLong_IsSmallInt(op));
313313
unsigned int flipped_sign = 2 - (op->long_value.lv_tag & SIGN_MASK);
314314
op->long_value.lv_tag &= NON_SIZE_MASK;
315315
op->long_value.lv_tag |= flipped_sign;

Modules/_testcapi/immortal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ test_immortal_small_ints(PyObject *self, PyObject *Py_UNUSED(ignored))
3131
for (int i = -5; i <= 1024; i++) {
3232
PyObject *obj = PyLong_FromLong(i);
3333
assert(verify_immortality(obj));
34-
int has_int_immortal_bit = _PyLong_HasImmortalTag((PyLongObject *)obj);
34+
int has_int_immortal_bit = _PyLong_IsSmallInt((PyLongObject *)obj);
3535
assert(has_int_immortal_bit);
3636
}
3737
for (int i = 1025; i <= 1030; i++) {
3838
PyObject *obj = PyLong_FromLong(i);
3939
assert(obj);
40-
int has_int_immortal_bit = _PyLong_HasImmortalTag((PyLongObject *)obj);
40+
int has_int_immortal_bit = _PyLong_IsSmallInt((PyLongObject *)obj);
4141
assert(!has_int_immortal_bit);
4242
Py_DECREF(obj);
4343
}

Objects/longobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3627,7 +3627,7 @@ void
36273627
_PyLong_ExactDealloc(PyObject *self)
36283628
{
36293629
assert(PyLong_CheckExact(self));
3630-
if (_PyLong_HasImmortalTag((PyLongObject *)self)) {
3630+
if (_PyLong_IsSmallInt((PyLongObject *)self)) {
36313631
// See PEP 683, section Accidental De-Immortalizing for details
36323632
_Py_SetImmortal(self);
36333633
return;
@@ -3642,7 +3642,7 @@ _PyLong_ExactDealloc(PyObject *self)
36423642
static void
36433643
long_dealloc(PyObject *self)
36443644
{
3645-
if (_PyLong_HasImmortalTag((PyLongObject *)self)) {
3645+
if (_PyLong_IsSmallInt((PyLongObject *)self)) {
36463646
/* This should never get called, but we also don't want to SEGV if
36473647
* we accidentally decref small Ints out of existence. Instead,
36483648
* since small Ints are immortal, re-set the reference count.

0 commit comments

Comments
 (0)