gh-114312: Collect stats for unlikely events (GH-114493)

This commit is contained in:
Michael Droettboom 2024-01-25 06:10:51 -05:00 • committed by GitHub
parent c63c6142f9
commit ea3cd0498c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 199 additions and 1 deletions

View file

@ -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