summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r--Python/optimizer_bytecodes.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index 040e544..f862c9c 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -370,6 +370,27 @@ dummy_func(void) {
res = sym_new_type(ctx, &PyUnicode_Type);
}
+ op(_BINARY_OP_SUBSCR_TUPLE_INT, (tuple_st, sub_st -- res)) {
+ assert(sym_matches_type(tuple_st, &PyTuple_Type));
+ if (sym_is_const(ctx, sub_st)) {
+ assert(PyLong_CheckExact(sym_get_const(ctx, sub_st)));
+ long index = PyLong_AsLong(sym_get_const(ctx, sub_st));
+ assert(index >= 0);
+ int tuple_length = sym_tuple_length(tuple_st);
+ if (tuple_length == -1) {
+ // Unknown length
+ res = sym_new_not_null(ctx);
+ }
+ else {
+ assert(index < tuple_length);
+ res = sym_tuple_getitem(ctx, tuple_st, index);
+ }
+ }
+ else {
+ res = sym_new_not_null(ctx);
+ }
+ }
+
op(_TO_BOOL, (value -- res)) {
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
if (!already_bool) {