@@ -818,6 +818,9 @@ def emit_test(self, node: ast.BoolOp, is_if_true: bool) -> None:
818818 def visitBoolOp (self , node : ast .BoolOp ) -> None :
819819 raise NotImplementedError ()
820820
821+ def emit_binary_subscr (self ) -> None :
822+ raise NotImplementedError ()
823+
821824 def emit_bin_op (self , binop : type [ast .operator ]) -> None :
822825 raise NotImplementedError ()
823826
@@ -1971,7 +1974,7 @@ def _pattern_helper_sequence_subscr(
19711974 self .emit ("GET_LEN" )
19721975 self .emit ("LOAD_CONST" , size - i )
19731976 self .emit_bin_op (ast .Sub )
1974- self .emit ( "BINARY_SUBSCR" )
1977+ self .emit_binary_subscr ( )
19751978 self .set_pos (pattern )
19761979 self ._visit_subpattern (pattern , pc )
19771980 self .set_pos (node )
@@ -3475,6 +3478,9 @@ def unaryOp(self, node: ast.UnaryOp, op: str) -> None:
34753478 ast .BitAnd : "BINARY_AND" ,
34763479 }
34773480
3481+ def emit_binary_subscr (self ) -> None :
3482+ self .emit ("BINARY_SUBSCR" )
3483+
34783484 def emit_bin_op (self , binop : type [ast .operator ]) -> None :
34793485 op = self ._binary_opcode [binop ]
34803486 self .emit (op )
@@ -3654,11 +3660,11 @@ def visitSubscript(self, node: ast.Subscript, aug_flag: bool = False) -> None:
36543660 self .visit (node .value )
36553661 self .visit (node .slice )
36563662 if isinstance (node .ctx , ast .Load ):
3657- self .emit ( "BINARY_SUBSCR" )
3663+ self .emit_binary_subscr ( )
36583664 elif isinstance (node .ctx , ast .Store ):
36593665 if aug_flag :
36603666 self .emit_dup (2 )
3661- self .emit ( "BINARY_SUBSCR" )
3667+ self .emit_binary_subscr ( )
36623668 else :
36633669 self .emit ("STORE_SUBSCR" )
36643670 elif isinstance (node .ctx , ast .Del ):
@@ -3748,7 +3754,7 @@ def emit_finish_match_class(self, node: ast.MatchClass, pc: PatternContext) -> N
37483754 continue
37493755 self .emit_dup ()
37503756 self .emit ("LOAD_CONST" , i )
3751- self .emit ( "BINARY_SUBSCR" )
3757+ self .emit_binary_subscr ( )
37523758 self ._visit_subpattern (pattern , pc )
37533759 # Success! Pop the tuple of attributes:
37543760 pc .on_top -= 1
@@ -3773,7 +3779,7 @@ def emit_finish_match_mapping(
37733779 continue
37743780 self .emit_dup ()
37753781 self .emit ("LOAD_CONST" , i )
3776- self .emit ( "BINARY_SUBSCR" )
3782+ self .emit_binary_subscr ( )
37773783 self ._visit_subpattern (pattern , pc )
37783784
37793785 # If we get this far, it's a match! We're done with the tuple of values,
@@ -4124,7 +4130,7 @@ def emitAugSubscript(self, node: ast.AugAssign) -> None:
41244130 self .visit (subs .slice )
41254131 self .emit ("COPY" , 2 )
41264132 self .emit ("COPY" , 2 )
4127- self .emit ( "BINARY_SUBSCR" )
4133+ self .emit_binary_subscr ( )
41284134
41294135 self .emitAugRHS (node )
41304136
@@ -4156,7 +4162,7 @@ def visitSubscript(self, node: ast.Subscript, aug_flag: bool = False) -> None:
41564162 self .visit (node .slice )
41574163
41584164 if isinstance (node .ctx , ast .Load ):
4159- self .emit ( "BINARY_SUBSCR" )
4165+ self .emit_binary_subscr ( )
41604166 elif isinstance (node .ctx , ast .Store ):
41614167 self .emit ("STORE_SUBSCR" )
41624168 elif isinstance (node .ctx , ast .Del ):
@@ -4204,6 +4210,9 @@ def emit_yield(self, scope: Scope) -> None:
42044210 ast .BitAnd : find_op_idx ("NB_AND" ),
42054211 }
42064212
4213+ def emit_binary_subscr (self ) -> None :
4214+ self .emit ("BINARY_SUBSCR" )
4215+
42074216 def emit_bin_op (self , binop : type [ast .operator ]) -> None :
42084217 op = self ._binary_opargs [binop ]
42094218 self .emit ("BINARY_OP" , op )
@@ -5923,6 +5932,9 @@ def optimize_tree(
59235932 assert isinstance (result , AST )
59245933 return result
59255934
5935+ def emit_binary_subscr (self ) -> None :
5936+ self .emit ("BINARY_OP" , self .find_op_idx ("NB_SUBSCR" ))
5937+
59265938 def emit_kwonlydefaults (self , node : FuncOrLambda ) -> bool :
59275939 default_count = 0
59285940 for kwonly , default in zip (node .args .kwonlyargs , node .args .kw_defaults ):
0 commit comments