Skip to content

Commit a5bd3f1

Browse files
committed
remove _PyOptimizer_NewCounter
1 parent b70a567 commit a5bd3f1

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
@@ -119,7 +119,6 @@ PyAPI_FUNC(void) _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj);
119119
// Export for '_testinternalcapi' shared extension.
120120
PyAPI_FUNC(_PyOptimizerObject *) _Py_GetOptimizer(void);
121121
PyAPI_FUNC(int) _Py_SetTier2Optimizer(_PyOptimizerObject* optimizer);
122-
PyAPI_FUNC(PyObject *) _PyOptimizer_NewCounter(void);
123122
PyAPI_FUNC(PyObject *) _PyOptimizer_NewUOpOptimizer(void);
124123

125124
#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
@@ -2085,35 +2085,6 @@ def callback(code, instruction_offset):
20852085
sys.monitoring.set_events(0, 0)
20862086

20872087

2088-
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
2089-
2090-
def setUp(self):
2091-
_testinternalcapi = import_module("_testinternalcapi")
2092-
if hasattr(_testinternalcapi, "get_optimizer"):
2093-
self.old_opt = _testinternalcapi.get_optimizer()
2094-
opt = _testinternalcapi.new_counter_optimizer()
2095-
_testinternalcapi.set_optimizer(opt)
2096-
super(TestOptimizer, self).setUp()
2097-
2098-
def tearDown(self):
2099-
super(TestOptimizer, self).tearDown()
2100-
import _testinternalcapi
2101-
if hasattr(_testinternalcapi, "get_optimizer"):
2102-
_testinternalcapi.set_optimizer(self.old_opt)
2103-
2104-
def test_for_loop(self):
2105-
def test_func(x):
2106-
i = 0
2107-
while i < x:
2108-
i += 1
2109-
2110-
code = test_func.__code__
2111-
sys.monitoring.set_local_events(TEST_TOOL, code, E.PY_START)
2112-
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), E.PY_START)
2113-
test_func(1000)
2114-
sys.monitoring.set_local_events(TEST_TOOL, code, 0)
2115-
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), 0)
2116-
21172088
class TestTier2Optimizer(CheckEvents):
21182089

21192090
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
{
@@ -2101,7 +2095,6 @@ static PyMethodDef module_functions[] = {
21012095
#ifdef _Py_TIER2
21022096
{"get_optimizer", get_optimizer, METH_NOARGS, NULL},
21032097
{"set_optimizer", set_optimizer, METH_O, NULL},
2104-
{"new_counter_optimizer", new_counter_optimizer, METH_NOARGS, NULL},
21052098
{"new_uop_optimizer", new_uop_optimizer, METH_NOARGS, NULL},
21062099
{"add_executor_dependency", add_executor_dependency, METH_VARARGS, NULL},
21072100
{"invalidate_executors", invalidate_executors, METH_O, NULL},

Python/optimizer.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,18 +1410,6 @@ PyTypeObject _PyCounterOptimizer_Type = {
14101410
.tp_dealloc = (destructor)PyObject_Free,
14111411
};
14121412

1413-
PyObject *
1414-
_PyOptimizer_NewCounter(void)
1415-
{
1416-
_PyCounterOptimizerObject *opt = (_PyCounterOptimizerObject *)_PyObject_New(&_PyCounterOptimizer_Type);
1417-
if (opt == NULL) {
1418-
return NULL;
1419-
}
1420-
opt->base.optimize = counter_optimize;
1421-
opt->count = 0;
1422-
return (PyObject *)opt;
1423-
}
1424-
14251413

14261414
/*****************************************
14271415
* Executor management

0 commit comments

Comments
 (0)