summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-10-25 11:31:16 (GMT)
committerGitHub <noreply@github.com>2018-10-25 11:31:16 (GMT)
commit9e00e80e213ebc37eff89ce72102c1f928ebc133 (patch)
tree50b24d69615a7994aeb4d776adc8666fcec5aafd /Objects/object.c
parentd7c3e5f0e89cb807093e33165815c8bbd3c00f4b (diff)
downloadcpython-9e00e80e213ebc37eff89ce72102c1f928ebc133.zip
cpython-9e00e80e213ebc37eff89ce72102c1f928ebc133.tar.gz
cpython-9e00e80e213ebc37eff89ce72102c1f928ebc133.tar.bz2
bpo-35053: Enhance tracemalloc to trace free lists (GH-10063)
tracemalloc now tries to update the traceback when an object is reused from a "free list" (optimization for faster object creation, used by the builtin list type for example). Changes: * Add _PyTraceMalloc_NewReference() function which tries to update the Python traceback of a Python object. * _Py_NewReference() now calls _PyTraceMalloc_NewReference(). * Add an unit test.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 00c0bad..4597b12 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1919,6 +1919,9 @@ _Py_ReadyTypes(void)
void
_Py_NewReference(PyObject *op)
{
+ if (_Py_tracemalloc_config.tracing) {
+ _PyTraceMalloc_NewReference(op);
+ }
_Py_INC_REFTOTAL;
op->ob_refcnt = 1;
_Py_AddToAllObjects(op, 1);