mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-114695: Add sys._clear_internal_caches
(GH-115152)
This commit is contained in:
parent
54bde5dcc3
commit
235cacff81
12 changed files with 130 additions and 84 deletions
|
@ -2127,6 +2127,22 @@ sys__clear_type_cache_impl(PyObject *module)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
sys._clear_internal_caches
|
||||
|
||||
Clear all internal performance-related caches.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
sys__clear_internal_caches_impl(PyObject *module)
|
||||
/*[clinic end generated code: output=0ee128670a4966d6 input=253e741ca744f6e8]*/
|
||||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
_Py_Executors_InvalidateAll(interp);
|
||||
PyType_ClearCache();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* Note that, for now, we do not have a per-interpreter equivalent
|
||||
for sys.is_finalizing(). */
|
||||
|
||||
|
@ -2461,6 +2477,7 @@ static PyMethodDef sys_methods[] = {
|
|||
{"audit", _PyCFunction_CAST(sys_audit), METH_FASTCALL, audit_doc },
|
||||
{"breakpointhook", _PyCFunction_CAST(sys_breakpointhook),
|
||||
METH_FASTCALL | METH_KEYWORDS, breakpointhook_doc},
|
||||
SYS__CLEAR_INTERNAL_CACHES_METHODDEF
|
||||
SYS__CLEAR_TYPE_CACHE_METHODDEF
|
||||
SYS__CURRENT_FRAMES_METHODDEF
|
||||
SYS__CURRENT_EXCEPTIONS_METHODDEF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue