summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2006-04-12 17:06:05 (GMT)
committerArmin Rigo <arigo@tunes.org>2006-04-12 17:06:05 (GMT)
commite170937af6463d92e95cea907964a23dff521f31 (patch)
treec8c4deb1ad0655eeedeef6754932db4afec7e930 /Objects/object.c
parent314fce92dd12a8ff82876bd18845a2249a931fae (diff)
downloadcpython-e170937af6463d92e95cea907964a23dff521f31.zip
cpython-e170937af6463d92e95cea907964a23dff521f31.tar.gz
cpython-e170937af6463d92e95cea907964a23dff521f31.tar.bz2
Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index e15218f..0ce4332 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -5,7 +5,24 @@
#ifdef Py_REF_DEBUG
Py_ssize_t _Py_RefTotal;
-#endif
+
+Py_ssize_t
+_Py_GetRefTotal(void)
+{
+ PyObject *o;
+ Py_ssize_t total = _Py_RefTotal;
+ /* ignore the references to the dummy object of the dicts and sets
+ because they are not reliable and not useful (now that the
+ hash table code is well-tested) */
+ o = _PyDict_Dummy();
+ if (o != NULL)
+ total -= o->ob_refcnt;
+ o = _PySet_Dummy();
+ if (o != NULL)
+ total -= o->ob_refcnt;
+ return total;
+}
+#endif /* Py_REF_DEBUG */
int Py_DivisionWarningFlag;