8000 gh-131798: JIT: Further optimize `_CALL_ISINSTANCE` for class tuples by tomasr8 · Pull Request #134543 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-131798: JIT: Further optimize _CALL_ISINSTANCE for class tuples #134543

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
Remove an extra test case
  • Loading branch information
tomasr8 committed Jul 5, 2025
commit 0465c9ab43597e101b26b4925b4e37078fd5d96d
30 changes: 0 additions & 30 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2286,36 +2286,6 @@ def testfunc(n):
self.assertNotIn("_TO_BOOL_BOOL", uops)
self.assertIn("_GUARD_IS_TRUE_POP", uops)

def test_call_isinstance_tuple_metaclass(self):
calls = 0

class Meta(type):
def __instancecheck__(self, _):
nonlocal calls
calls += 1
return False

class Unknown(metaclass=Meta):
pass

def testfunc(n):
x = 0
for _ in range(n):
# Only narrowed to bool
y = isinstance(42, (Unknown, int))
if y:
x += 1
return x, calls

(res, calls), ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertEqual(calls, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_TO_BOOL_BOOL", uops)
self.assertIn("_GUARD_IS_TRUE_POP", uops)

def test_set_type_version_sets_type(self):
class C:
A = 1
Expand Down
Loading
0