Skip to content

Commit 56fc4e1

Browse files
committed
Add comment about _Py_IMMORTAL_REFCNT in Py_INCREF()
1 parent 6864e53 commit 56fc4e1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Include/object.h

+3
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
758758
uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local);
759759
uint32_t new_local = local + 1;
760760
if (new_local == 0) {
761+
// local is equal to _Py_IMMORTAL_REFCNT: do nothing
761762
return;
762763
}
763764
if (_Py_IsOwnedByCurrentThread(op)) {
@@ -771,6 +772,8 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
771772
PY_UINT32_T cur_refcnt = op->ob_refcnt_split[PY_BIG_ENDIAN];
772773
PY_UINT32_T new_refcnt = cur_refcnt + 1;
773774
if (new_refcnt == 0) {
775+
// cur_refcnt is equal to _Py_IMMORTAL_REFCNT: the object is immortal,
776+
// do nothing
774777
return;
775778
}
776779
op->ob_refcnt_split[PY_BIG_ENDIAN] = new_refcnt;

0 commit comments

Comments
 (0)