summaryrefslogtreecommitdiffstats
path: root/Modules
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 /Modules
parent601ae09f0c8eda213b9050892f5ce9b91f0aa522 (diff)
downloadcpython-4bfa01b9d911ce9358cf1a453bee15554f8e4c07.zip
cpython-4bfa01b9d911ce9358cf1a453bee15554f8e4c07.tar.gz
cpython-4bfa01b9d911ce9358cf1a453bee15554f8e4c07.tar.bz2
GH-104584: Plugin optimizer API (GH-105100)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 8267dbf..b43dc7f 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -822,6 +822,22 @@ iframe_getlasti(PyObject *self, PyObject *frame)
return PyLong_FromLong(PyUnstable_InterpreterFrame_GetLasti(f));
}
+static PyObject *
+get_counter_optimizer(PyObject *self, PyObject *arg)
+{
+ return PyUnstable_Optimizer_NewCounter();
+}
+
+static PyObject *
+set_optimizer(PyObject *self, PyObject *opt)
+{
+ if (opt == Py_None) {
+ opt = NULL;
+ }
+ PyUnstable_SetOptimizer((_PyOptimizerObject*)opt);
+ Py_RETURN_NONE;
+}
+
static PyMethodDef module_functions[] = {
{"get_configs", get_configs, METH_NOARGS},
{"get_recursion_depth", get_recursion_depth, METH_NOARGS},
@@ -850,6 +866,8 @@ static PyMethodDef module_functions[] = {
{"iframe_getcode", iframe_getcode, METH_O, NULL},
{"iframe_getline", iframe_getline, METH_O, NULL},
{"iframe_getlasti", iframe_getlasti, METH_O, NULL},
+ {"set_optimizer", set_optimizer, METH_O, NULL},
+ {"get_counter_optimizer", get_counter_optimizer, METH_NOARGS, NULL},
{NULL, NULL} /* sentinel */
};