aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/optimizer_bytecodes.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-06-05 18:53:57 +0100
committerGitHub <noreply@github.com>2025-06-05 18:53:57 +0100
commitb90ecea9e6b33dae360ed7eb2c32598f98444c4d (patch)
treef3a57abedd7c6bbac6141dc792eb8a4d976b950b /Python/optimizer_bytecodes.c
parentd9cad074d52fe31327429fd81e4d2eeea3dbe35b (diff)
downloadcpython-b90ecea9e6b33dae360ed7eb2c32598f98444c4d.tar.gz
cpython-b90ecea9e6b33dae360ed7eb2c32598f98444c4d.zip
GH-132554: Fix tier2 `FOR_ITER` implementation and optimizations (GH-135137)
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r--Python/optimizer_bytecodes.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index e1209209660..b4220e2c627 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -840,6 +840,17 @@ dummy_func(void) {
value = sym_new_unknown(ctx);
}
+ op(_GET_ITER, (iterable -- iter, index_or_null)) {
+ if (sym_matches_type(iterable, &PyTuple_Type) || sym_matches_type(iterable, &PyList_Type)) {
+ iter = iterable;
+ index_or_null = sym_new_not_null(ctx);
+ }
+ else {
+ iter = sym_new_not_null(ctx);
+ index_or_null = sym_new_unknown(ctx);
+ }
+ }
+
op(_FOR_ITER_GEN_FRAME, (unused, unused -- unused, unused, gen_frame: _Py_UOpsAbstractFrame*)) {
gen_frame = NULL;
/* We are about to hit the end of the trace */