diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2025-02-07 22:39:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-07 22:39:54 +0000 |
commit | a1417b211f0bb9582b00f7b82d0a43a3bcc9ed05 (patch) | |
tree | 1133960d5abf1077cbf974bcde2ecb90b9fc1b7c /Python/codegen.c | |
parent | 2248a9c153092b920ff68b0eee009c04dbe19f61 (diff) | |
download | cpython-a1417b211f0bb9582b00f7b82d0a43a3bcc9ed05.tar.gz cpython-a1417b211f0bb9582b00f7b82d0a43a3bcc9ed05.zip |
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700)
Diffstat (limited to 'Python/codegen.c')
-rw-r--r-- | Python/codegen.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Python/codegen.c b/Python/codegen.c index e9853d7302f..cd77b34c062 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -5076,7 +5076,7 @@ codegen_augassign(compiler *c, stmt_ty s) VISIT(c, expr, e->v.Subscript.slice); ADDOP_I(c, loc, COPY, 2); ADDOP_I(c, loc, COPY, 2); - ADDOP(c, loc, BINARY_SUBSCR); + ADDOP_I(c, loc, BINARY_OP, NB_SUBSCR); } break; case Name_kind: @@ -5242,7 +5242,6 @@ codegen_subscript(compiler *c, expr_ty e) { location loc = LOC(e); expr_context_ty ctx = e->v.Subscript.ctx; - int op = 0; if (ctx == Load) { RETURN_IF_ERROR(check_subscripter(c, e->v.Subscript.value)); @@ -5265,12 +5264,16 @@ codegen_subscript(compiler *c, expr_ty e) else { VISIT(c, expr, e->v.Subscript.slice); switch (ctx) { - case Load: op = BINARY_SUBSCR; break; - case Store: op = STORE_SUBSCR; break; - case Del: op = DELETE_SUBSCR; break; + case Load: + ADDOP_I(c, loc, BINARY_OP, NB_SUBSCR); + break; + case Store: + ADDOP(c, loc, STORE_SUBSCR); + break; + case Del: + ADDOP(c, loc, DELETE_SUBSCR); + break; } - assert(op); - ADDOP(c, loc, op); } return SUCCESS; } @@ -5502,7 +5505,7 @@ pattern_helper_sequence_unpack(compiler *c, location loc, return SUCCESS; } -// Like pattern_helper_sequence_unpack, but uses BINARY_SUBSCR instead of +// Like pattern_helper_sequence_unpack, but uses BINARY_OP/NB_SUBSCR instead of // UNPACK_SEQUENCE / UNPACK_EX. This is more efficient for patterns with a // starred wildcard like [first, *_] / [first, *_, last] / [*_, last] / etc. static int @@ -5533,7 +5536,7 @@ pattern_helper_sequence_subscr(compiler *c, location loc, ADDOP_LOAD_CONST_NEW(c, loc, PyLong_FromSsize_t(size - i)); ADDOP_BINARY(c, loc, Sub); } - ADDOP(c, loc, BINARY_SUBSCR); + ADDOP_I(c, loc, BINARY_OP, NB_SUBSCR); RETURN_IF_ERROR(codegen_pattern_subpattern(c, pattern, pc)); } // Pop the subject, we're done with it: |