Skip to content

Commit c5d5d75

Browse files
add recording to CALL_KW_BOUND_METHOD
1 parent f28b5e0 commit c5d5d75

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5270,6 +5270,26 @@ def testfunc(n):
52705270
self.assertIn("_PUSH_FRAME", uops)
52715271
self.assertIn("_CHECK_FUNCTION_VERSION_KW", uops)
52725272

5273+
def test_call_kw_bound_method(self):
5274+
class C:
5275+
def method(self, a):
5276+
return 42 * a
5277+
5278+
def testfunc(n):
5279+
obj = C()
5280+
x = 0
5281+
meth = obj.method
5282+
for _ in range(n):
5283+
x += meth(a=1)
5284+
return x
5285+
5286+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
5287+
self.assertEqual(res, 42 * TIER2_THRESHOLD)
5288+
self.assertIsNotNone(ex)
5289+
uops = get_opnames(ex)
5290+
self.assertIn("_PUSH_FRAME", uops)
5291+
self.assertIn("_CHECK_METHOD_VERSION_KW", uops)
5292+
52735293
def test_func_version_guarded_on_change(self):
52745294
def testfunc(n):
52755295
for i in range(n):

Python/bytecodes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5280,6 +5280,7 @@ dummy_func(
52805280
}
52815281

52825282
macro(CALL_KW_BOUND_METHOD) =
5283+
_RECORD_CALLABLE_KW +
52835284
unused/1 + // Skip over the counter
52845285
_CHECK_PEP_523 +
52855286
_CHECK_METHOD_VERSION_KW +

Python/record_functions.c.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)