summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-06-02 10:46:18 (GMT)
committerGitHub <noreply@github.com>2023-06-02 10:46:18 (GMT)
commit4bfa01b9d911ce9358cf1a453bee15554f8e4c07 (patch)
treebd61d8459bf30d42abf0be7258de91360bea434b /Python/pystate.c
parent601ae09f0c8eda213b9050892f5ce9b91f0aa522 (diff)
downloadcpython-4bfa01b9d911ce9358cf1a453bee15554f8e4c07.zip
cpython-4bfa01b9d911ce9358cf1a453bee15554f8e4c07.tar.gz
cpython-4bfa01b9d911ce9358cf1a453bee15554f8e4c07.tar.bz2
GH-104584: Plugin optimizer API (GH-105100)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 39fe547..5b7a6c8 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -695,6 +695,9 @@ init_interpreter(PyInterpreterState *interp,
}
interp->sys_profile_initialized = false;
interp->sys_trace_initialized = false;
+ interp->optimizer = &_PyOptimizer_Default;
+ interp->optimizer_backedge_threshold = _PyOptimizer_Default.backedge_threshold;
+ interp->optimizer_resume_threshold = _PyOptimizer_Default.backedge_threshold;
if (interp != &runtime->_main_interpreter) {
/* Fix the self-referential, statically initialized fields. */
interp->dtoa = (struct _dtoa_state)_dtoa_state_INIT(interp);
@@ -829,6 +832,11 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
tstate->_status.cleared = 0;
}
+ Py_CLEAR(interp->optimizer);
+ interp->optimizer = &_PyOptimizer_Default;
+ interp->optimizer_backedge_threshold = _PyOptimizer_Default.backedge_threshold;
+ interp->optimizer_resume_threshold = _PyOptimizer_Default.backedge_threshold;
+
/* It is possible that any of the objects below have a finalizer
that runs Python code or otherwise relies on a thread state
or even the interpreter state. For now we trust that isn't