summaryrefslogtreecommitdiffstats
path: root/Modules/_testinternalcapi.c
diff options
context:
space:
mode:
authorMichael Droettboom <mdboom@gmail.com>2024-01-25 11:10:51 (GMT)
committerGitHub <noreply@github.com>2024-01-25 11:10:51 (GMT)
commitea3cd0498c443e93be441736c804258e93d21edd (patch)
treeab975dc0fe8c933fd2c197275a7d9fc6598aa04b /Modules/_testinternalcapi.c
parentc63c6142f9146e1e977f4c824c56e8979e6aca87 (diff)
downloadcpython-ea3cd0498c443e93be441736c804258e93d21edd.zip
cpython-ea3cd0498c443e93be441736c804258e93d21edd.tar.gz
cpython-ea3cd0498c443e93be441736c804258e93d21edd.tar.bz2
gh-114312: Collect stats for unlikely events (GH-114493)
Diffstat (limited to 'Modules/_testinternalcapi.c')
-rw-r--r--Modules/_testinternalcapi.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 7d277df..2c32c69 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -1635,6 +1635,21 @@ get_type_module_name(PyObject *self, PyObject *type)
return _PyType_GetModuleName((PyTypeObject *)type);
}
+static PyObject *
+get_rare_event_counters(PyObject *self, PyObject *type)
+{
+ PyInterpreterState *interp = PyInterpreterState_Get();
+
+ return Py_BuildValue(
+ "{sksksksksk}",
+ "set_class", interp->rare_events.set_class,
+ "set_bases", interp->rare_events.set_bases,
+ "set_eval_frame_func", interp->rare_events.set_eval_frame_func,
+ "builtin_dict", interp->rare_events.builtin_dict,
+ "func_modification", interp->rare_events.func_modification
+ );
+}
+
#ifdef Py_GIL_DISABLED
static PyObject *
@@ -1711,6 +1726,7 @@ static PyMethodDef module_functions[] = {
{"restore_crossinterp_data", restore_crossinterp_data, METH_VARARGS},
_TESTINTERNALCAPI_TEST_LONG_NUMBITS_METHODDEF
{"get_type_module_name", get_type_module_name, METH_O},
+ {"get_rare_event_counters", get_rare_event_counters, METH_NOARGS},
#ifdef Py_GIL_DISABLED
{"py_thread_id", get_py_thread_id, METH_NOARGS},
#endif