summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c8
-rw-r--r--Objects/object.c19
-rw-r--r--Objects/setobject.c8
3 files changed, 34 insertions, 1 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index f6fa1eb9e4..31ef958e63 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -115,6 +115,14 @@ equally good collision statistics, needed less code & used less memory.
/* Object used as dummy key to fill deleted entries */
static PyObject *dummy = NULL; /* Initialized by first call to newdictobject() */
+#ifdef Py_REF_DEBUG
+PyObject *
+_PyDict_Dummy(void)
+{
+ return dummy;
+}
+#endif
+
/* forward declarations */
static dictentry *
lookdict_string(dictobject *mp, PyObject *key, long hash);
diff --git a/Objects/object.c b/Objects/object.c
index e15218fa23..0ce4332f76 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;
diff --git a/Objects/setobject.c b/Objects/setobject.c
index edc43df574..e7f6e09fec 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -16,6 +16,14 @@
/* Object used as dummy key to fill deleted entries */
static PyObject *dummy = NULL; /* Initialized by first call to make_new_set() */
+#ifdef Py_REF_DEBUG
+PyObject *
+_PySet_Dummy(void)
+{
+ return dummy;
+}
+#endif
+
#define INIT_NONZERO_SET_SLOTS(so) do { \
(so)->table = (so)->smalltable; \
(so)->mask = PySet_MINSIZE - 1; \