summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-05-16 13:35:11 (GMT)
committerGitHub <noreply@github.com>2022-05-16 13:35:11 (GMT)
commitfa2b8b75eb2b8a0193d587e02b488a73579118fc (patch)
tree023f4ceed47906c30c68348c032a38707ec5516f /Include/object.h
parentf6fd8aac13714ce17650eb4a648d5c08f0be53b4 (diff)
downloadcpython-fa2b8b75eb2b8a0193d587e02b488a73579118fc.zip
cpython-fa2b8b75eb2b8a0193d587e02b488a73579118fc.tar.gz
cpython-fa2b8b75eb2b8a0193d587e02b488a73579118fc.tar.bz2
Improve object stats (#92845)
* Add incref/decref stats * Show ratios for allocation in summary
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/Include/object.h b/Include/object.h
index f2af428..f01b9fa 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -51,6 +51,8 @@ A standard interface exists for objects that contain an array of items
whose size is determined when the object is allocated.
*/
+#include "pystats.h"
+
/* Py_DEBUG implies Py_REF_DEBUG. */
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
# define Py_REF_DEBUG
@@ -490,6 +492,7 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);
static inline void Py_INCREF(PyObject *op)
{
+ _Py_INCREF_STAT_INC();
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000
// Stable ABI for Python 3.10 built in debug mode.
_Py_IncRef(op);
@@ -506,7 +509,6 @@ static inline void Py_INCREF(PyObject *op)
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
#endif
-
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000
// Stable ABI for limited C API version 3.10 of Python debug build
static inline void Py_DECREF(PyObject *op) {
@@ -517,6 +519,7 @@ static inline void Py_DECREF(PyObject *op) {
#elif defined(Py_REF_DEBUG)
static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
{
+ _Py_DECREF_STAT_INC();
_Py_RefTotal--;
if (--op->ob_refcnt != 0) {
if (op->ob_refcnt < 0) {
@@ -532,6 +535,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
#else
static inline void Py_DECREF(PyObject *op)
{
+ _Py_DECREF_STAT_INC();
// Non-limited C API and limited C API for Python 3.9 and older access
// directly PyObject.ob_refcnt.
if (--op->ob_refcnt == 0) {