]> granicus.if.org Git - python/commitdiff
Added a new debug method sys.gettotalrefcount(), which returns the total number of...
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 20 Jun 2000 08:12:48 +0000 (08:12 +0000)
committerMark Hammond <mhammond@skippinet.com.au>
Tue, 20 Jun 2000 08:12:48 +0000 (08:12 +0000)
Also removed a redundant cast from sys.getrefcount(), as discussed on the patches list.

Python/sysmodule.c

index ea838ebd68ae381f1cf3ad28c1b159ff121ec064..6219454ed61fd516043021d735d58135b0be24c8 100644 (file)
@@ -265,9 +265,21 @@ sys_getrefcount(self, args)
        PyObject *arg;
        if (!PyArg_ParseTuple(args, "O:getrefcount", &arg))
                return NULL;
-       return PyInt_FromLong((long) arg->ob_refcnt);
+       return PyInt_FromLong(arg->ob_refcnt);
 }
 
+#ifdef Py_TRACE_REFS
+static PyObject *
+sys_gettotalrefcount(PyObject *self, PyObject *args)
+{
+       extern long _Py_RefTotal;
+       if (!PyArg_ParseTuple(args, ":gettotalrefcount"))
+               return NULL;
+       return PyInt_FromLong(_Py_RefTotal);
+}
+
+#endif /* Py_TRACE_REFS */
+
 static char getrefcount_doc[] =
 "getrefcount(object) -> integer\n\
 \n\
@@ -310,6 +322,7 @@ static PyMethodDef sys_methods[] = {
 #endif
 #ifdef Py_TRACE_REFS
        {"getobjects",  _Py_GetObjects, 1},
+       {"gettotalrefcount", sys_gettotalrefcount, 1},
 #endif
        {"getrefcount", sys_getrefcount, 1, getrefcount_doc},
 #ifdef USE_MALLOPT