Skip to content

Commit 21cca47

Browse files
committed
remove _PyOptimizer_NewCounter
1 parent c5438fd commit 21cca47

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
@@ -2003,35 +2003,6 @@ def callback(code, instruction_offset):
20032003
sys.monitoring.set_events(0, 0)
20042004

20052005

2006-
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
2007-
2008-
def setUp(self):
2009-
_testinternalcapi = import_module("_testinternalcapi")
2010-
if hasattr(_testinternalcapi, "get_optimizer"):
2011-
self.old_opt = _testinternalcapi.get_optimizer()
2012-
opt = _testinternalcapi.new_counter_optimizer()
2013-
_testinternalcapi.set_optimizer(opt)
2014-
super(TestOptimizer, self).setUp()
2015-
2016-
def tearDown(self):
2017-
super(TestOptimizer, self).tearDown()
2018-
import _testinternalcapi
2019-
if hasattr(_testinternalcapi, "get_optimizer"):
2020-
_testinternalcapi.set_optimizer(self.old_opt)
2021-
2022-
def test_for_loop(self):
2023-
def test_func(x):
2024-
i = 0
2025-
while i < x:
2026-
i += 1
2027-
2028-
code = test_func.__code__
2029-
sys.monitoring.set_local_events(TEST_TOOL, code, E.PY_START)
2030-
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), E.PY_START)
2031-
test_func(1000)
2032-
sys.monitoring.set_local_events(TEST_TOOL, code, 0)
2033-
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), 0)
2034-
20352006
class TestTier2Optimizer(CheckEvents):
20362007

20372008
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
@@ -1404,18 +1404,6 @@ PyTypeObject _PyCounterOptimizer_Type = {
14041404
.tp_dealloc = (destructor)PyObject_Free,
14051405
};
14061406

1407-
PyObject *
1408-
_PyOptimizer_NewCounter(void)
1409-
{
1410-
_PyCounterOptimizerObject *opt = (_PyCounterOptimizerObject *)_PyObject_New(&_PyCounterOptimizer_Type);
1411-
if (opt == NULL) {
1412-
return NULL;
1413-
}
1414-
opt->base.optimize = counter_optimize;
1415-
opt->count = 0;
1416-
return (PyObject *)opt;
1417-
}
1418-
14191407

14201408
/*****************************************
14211409
* Executor management

0 commit comments

Comments
 (0)