Skip to content

Commit 644e85a

Browse files
committed
review comments part 1
1 parent d1e4aa2 commit 644e85a

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Objects/longobject.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "pycore_bitutils.h" // _Py_popcount32()
77
#include "pycore_initconfig.h" // _PyStatus_OK()
88
#include "pycore_call.h" // _PyObject_MakeTpCall
9-
#include "pycore_freelist.h" // _Py_FREELIST_FREE(), _Py_FREELIST_POP()
9+
#include "pycore_freelist.h" // _Py_FREELIST_FREE, _Py_FREELIST_POP
1010
#include "pycore_long.h" // _Py_SmallInts
1111
#include "pycore_object.h" // _PyObject_Init()
1212
#include "pycore_runtime.h" // _PY_NSMALLPOSINTS
@@ -43,7 +43,7 @@ static inline void
4343
_Py_DECREF_INT(PyLongObject *op)
4444
{
4545
assert(PyLong_CheckExact(op));
46-
_Py_DECREF_SPECIALIZED((PyObject *)op, (destructor) _PyLong_ExactDealloc);
46+
_Py_DECREF_SPECIALIZED((PyObject *)op, _PyLong_ExactDealloc);
4747
}
4848

4949
static inline int
@@ -3631,26 +3631,24 @@ static void
36313631
long_dealloc(PyObject *self)
36323632
{
36333633
PyLongObject *pylong = (PyLongObject*)self;
3634+
assert(pylong);
36343635

3635-
if (pylong && _PyLong_IsCompact(pylong)) {
3636+
if (_PyLong_IsCompact(pylong)) {
36363637
stwodigits ival = medium_value(pylong);
36373638
if (IS_SMALL_INT(ival)) {
36383639
PyLongObject *small_pylong = (PyLongObject *)get_small_int((sdigit)ival);
36393640
if (pylong == small_pylong) {
36403641
/* This should never get called, but we also don't want to SEGV if
3641-
* we accidentally decref small Ints out of existence. Instead,
3642-
* since small Ints are immortal, re-set the reference count.
3643-
*/
3644-
// can we remove the next two lines? the immortal objects now have a fixed refcount
3645-
// in particular in the free-threading build this seeems safe
3642+
* we accidentally decref small Ints out of existence. Instead,
3643+
* since small Ints are immortal, re-set the reference count.
3644+
*
3645+
* With a fixed refcount for immortal objects this should not happen
3646+
*/
36463647
_Py_SetImmortal(self);
36473648
return;
36483649
}
36493650
}
3650-
}
3651-
3652-
if (PyLong_CheckExact(self)) {
3653-
if (_PyLong_IsCompact((PyLongObject *)self)) {
3651+
if (PyLong_CheckExact(self)) {
36543652
_Py_FREELIST_FREE(ints, self, PyObject_Free);
36553653
return;
36563654
}
@@ -6642,7 +6640,7 @@ PyTypeObject PyLong_Type = {
66426640
0, /* tp_init */
66436641
0, /* tp_alloc */
66446642
long_new, /* tp_new */
6645-
(freefunc)PyObject_Free, /* tp_free */
6643+
PyObject_Free, /* tp_free */
66466644
.tp_vectorcall = long_vectorcall,
66476645
.tp_version_tag = _Py_TYPE_VERSION_INT,
66486646
};

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
2727
#include "pycore_pystate.h" // _PyInterpreterState_GET()
2828
#include "pycore_range.h" // _PyRangeIterObject
29-
#include "pycore_long.h" // void _PyLong_ExactDealloc(PyLongObject *op);
29+
#include "pycore_long.h" // _PyLong_ExactDealloc()
3030
#include "pycore_setobject.h" // _PySet_NextEntry()
3131
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
3232
#include "pycore_tuple.h" // _PyTuple_ITEMS()

0 commit comments

Comments
 (0)