Skip to content

Commit 79d81f7

Browse files
authored
gh-131798: Optimize _ITER_CHECK_TUPLE (GH-134803)
1 parent ac539e7 commit 79d81f7

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow the JIT to remove unnecessary ``_ITER_CHECK_TUPLE`` ops.

Python/optimizer_bytecodes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,13 @@ dummy_func(void) {
914914
}
915915
}
916916

917+
op(_ITER_CHECK_TUPLE, (iter, null_or_index -- iter, null_or_index)) {
918+
if (sym_matches_type(iter, &PyTuple_Type)) {
919+
REPLACE_OP(this_instr, _NOP, 0, 0);
920+
}
921+
sym_set_type(iter, &PyTuple_Type);
922+
}
923+
917924
op(_ITER_NEXT_RANGE, (iter, null_or_index -- iter, null_or_index, next)) {
918925
next = sym_new_type(ctx, &PyLong_Type);
919926
}

Python/optimizer_cases.c.h

Lines changed: 6 additions & 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)