Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-131798: JIT: Narrow the return type of _GET_LEN to int #133345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix review idea
Signed-off-by: Manjusaka <me@manjusaka.me>
  • Loading branch information
Zheaoli committed May 20, 2025
commit 6b5282fbaee0d1c2fa9ef53f3b99b271531a7486
33 changes: 1 addition & 32 deletions 33 Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1937,23 +1937,8 @@ def testfunc(n):
self.assertEqual(len(res), TIER2_THRESHOLD)
uops = get_opnames(ex)
self.assertNotIn("_GUARD_NOS_INT", uops)
Zheaoli marked this conversation as resolved.
Show resolved Hide resolved
self.assertIn("_GET_LEN", uops)
self.assertIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
self.assertIn("_LOAD_CONST_INLINE_BORROW", uops)

def test_get_len_with_non_const_tuple(self):
def testfunc(n):
x = 0.0
for _ in range(n):
match (object(), object()):
case [_, _]:
x += 1.0
return x
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(int(res), TIER2_THRESHOLD)
uops = get_opnames(ex)
self.assertNotIn("_GUARD_NOS_INT", uops)
self.assertIn("_GET_LEN", uops)
self.assertIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)

def test_get_len_with_non_tuple(self):
def testfunc(n):
Expand All @@ -1969,22 +1954,6 @@ def testfunc(n):
self.assertNotIn("_GUARD_NOS_INT", uops)
self.assertIn("_GET_LEN", uops)

def test_get_len_with_immortal_tuple(self):
def testfunc(n):
class TestObject:
pass
x = 0.0
for _ in range(n):
match TestObject.__mro__:
case (_, _,):
x += 1.0
return x
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(int(res), TIER2_THRESHOLD)
uops = get_opnames(ex)
self.assertIn("_GET_LEN", uops)
self.assertIn("_LOAD_CONST_INLINE_BORROW", uops)


def test_binary_op_subscr_tuple_int(self):
def testfunc(n):
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.