Mercurial > cpython-lru_cache-weakref
diff Objects/object.c @ 37638:65ecb83ea7dd legacy-trunk
Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
| author | Armin Rigo <arigo@tunes.org> |
|---|---|
| date | Wed, 12 Apr 2006 17:06:05 +0000 |
| parents | e60b31647a6b |
| children | 2f3f2e32dfd9 |
line wrap: on
line diff
--- a/Objects/object.c Wed Apr 12 15:28:49 2006 +0000 +++ b/Objects/object.c Wed Apr 12 17:06:05 2006 +0000 @@ -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;
