mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
This commit is contained in:
parent
314fce92dd
commit
e170937af6
6 changed files with 40 additions and 5 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue