Skip to content

Commit 720c99e

Browse files
committed
remove _PyOptimizer_NewCounter
1 parent cc813e1 commit 720c99e

File tree

4 files changed

+0
-49
lines changed

4 files changed

+0
-49
lines changed

Include/internal/pycore_optimizer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ PyAPI_FUNC(void) _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj);
116116
// Export for '_testinternalcapi' shared extension.
117117
PyAPI_FUNC(_PyOptimizerObject *) _Py_GetOptimizer(void);
118118
PyAPI_FUNC(int) _Py_SetTier2Optimizer(_PyOptimizerObject* optimizer);
119-
PyAPI_FUNC(PyObject *) _PyOptimizer_NewCounter(void);
120119
PyAPI_FUNC(PyObject *) _PyOptimizer_NewUOpOptimizer(void);
121120

122121
#define _Py_MAX_ALLOWED_BUILTINS_MODIFICATIONS 3

Lib/test/test_monitoring.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,35 +1959,6 @@ def callback(code, instruction_offset):
19591959
sys.monitoring.set_events(0, 0)
19601960

19611961

1962-
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
1963-
1964-
def setUp(self):
1965-
_testinternalcapi = import_module("_testinternalcapi")
1966-
if hasattr(_testinternalcapi, "get_optimizer"):
1967-
self.old_opt = _testinternalcapi.get_optimizer()
1968-
opt = _testinternalcapi.new_counter_optimizer()
1969-
_testinternalcapi.set_optimizer(opt)
1970-
super(TestOptimizer, self).setUp()
1971-
1972-
def tearDown(self):
1973-
super(TestOptimizer, self).tearDown()
1974-
import _testinternalcapi
1975-
if hasattr(_testinternalcapi, "get_optimizer"):
1976-
_testinternalcapi.set_optimizer(self.old_opt)
1977-
1978-
def test_for_loop(self):
1979-
def test_func(x):
1980-
i = 0
1981-
while i < x:
1982-
i += 1
1983-
1984-
code = test_func.__code__
1985-
sys.monitoring.set_local_events(TEST_TOOL, code, E.PY_START)
1986-
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), E.PY_START)
1987-
test_func(1000)
1988-
sys.monitoring.set_local_events(TEST_TOOL, code, 0)
1989-
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), 0)
1990-
19911962
class TestTier2Optimizer(CheckEvents):
19921963

19931964
def test_monitoring_already_opimized_loop(self):

Modules/_testinternalcapi.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -989,12 +989,6 @@ get_co_framesize(PyObject *self, PyObject *arg)
989989

990990
#ifdef _Py_TIER2
991991

992-
static PyObject *
993-
new_counter_optimizer(PyObject *self, PyObject *arg)
994-
{
995-
return _PyOptimizer_NewCounter();
996-
}
997-
998992
static PyObject *
999993
new_uop_optimizer(PyObject *self, PyObject *arg)
1000994
{
@@ -2112,7 +2106,6 @@ static PyMethodDef module_functions[] = {
21122106
#ifdef _Py_TIER2
21132107
{"get_optimizer", get_optimizer, METH_NOARGS, NULL},
21142108
{"set_optimizer", set_optimizer, METH_O, NULL},
2115-
{"new_counter_optimizer", new_counter_optimizer, METH_NOARGS, NULL},
21162109
{"new_uop_optimizer", new_uop_optimizer, METH_NOARGS, NULL},
21172110
{"add_executor_dependency", add_executor_dependency, METH_VARARGS, NULL},
21182111
{"invalidate_executors", invalidate_executors, METH_O, NULL},

Python/optimizer.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,18 +1397,6 @@ PyTypeObject _PyCounterOptimizer_Type = {
13971397
.tp_dealloc = (destructor)PyObject_Free,
13981398
};
13991399

1400-
PyObject *
1401-
_PyOptimizer_NewCounter(void)
1402-
{
1403-
_PyCounterOptimizerObject *opt = (_PyCounterOptimizerObject *)_PyObject_New(&_PyCounterOptimizer_Type);
1404-
if (opt == NULL) {
1405-
return NULL;
1406-
}
1407-
opt->base.optimize = counter_optimize;
1408-
opt->count = 0;
1409-
return (PyObject *)opt;
1410-
}
1411-
14121400

14131401
/*****************************************
14141402
* Executor management

0 commit comments

Comments
 (0)