Commit 4be93d0e authored by Tim Peters's avatar Tim Peters

Rearranged and added comments to object.h, to clarify many things

that have taken me "too long" to reverse-engineer over the years.
Vastly reduced the nesting level and redundancy of #ifdef-ery.
Took a light stab at repairing comments that are no longer true.

sys_gettotalrefcount():  Changed to enable under Py_REF_DEBUG.
It was enabled under Py_TRACE_REFS, which was much heavier than
necessary.  sys.gettotalrefcount() is now available in a
Py_REF_DEBUG-only build.
parent 144dea3e
This diff is collapsed.
......@@ -1858,9 +1858,7 @@ _Py_NewReference(PyObject *op)
op->_ob_prev = &refchain;
refchain._ob_next->_ob_prev = op;
refchain._ob_next = op;
#ifdef COUNT_ALLOCS
inc_count(op->ob_type);
#endif
_PyMAYBE_BUMP_COUNT(op);
}
void
......@@ -1885,9 +1883,7 @@ _Py_ForgetReference(register PyObject *op)
op->_ob_next->_ob_prev = op->_ob_prev;
op->_ob_prev->_ob_next = op->_ob_next;
op->_ob_next = op->_ob_prev = NULL;
#ifdef COUNT_ALLOCS
op->ob_type->tp_frees++;
#endif
_PyMAYBE_BUMP_FREECOUNT(op);
}
void
......
......@@ -469,11 +469,10 @@ sys_getrefcount(PyObject *self, PyObject *arg)
return PyInt_FromLong(arg->ob_refcnt);
}
#ifdef Py_TRACE_REFS
#ifdef Py_REF_DEBUG
static PyObject *
sys_gettotalrefcount(PyObject *self)
{
extern long _Py_RefTotal;
return PyInt_FromLong(_Py_RefTotal);
}
......@@ -564,6 +563,8 @@ static PyMethodDef sys_methods[] = {
#endif
#ifdef Py_TRACE_REFS
{"getobjects", _Py_GetObjects, METH_VARARGS},
#endif
#ifdef Py_REF_DEBUG
{"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS},
#endif
{"getrefcount", (PyCFunction)sys_getrefcount, METH_O, getrefcount_doc},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment