diff options
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r-- | Python/optimizer_bytecodes.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index 4f96140..ff2830d 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -967,6 +967,16 @@ dummy_func(void) { } } + op(_CALL_TUPLE_1, (callable, null, arg -- res)) { + if (sym_matches_type(arg, &PyTuple_Type)) { + // e.g. tuple((1, 2)) or tuple(foo) where foo is known to be a tuple + res = arg; + } + else { + res = sym_new_type(ctx, &PyTuple_Type); + } + } + op(_GUARD_TOS_LIST, (tos -- tos)) { if (sym_matches_type(tos, &PyList_Type)) { REPLACE_OP(this_instr, _NOP, 0, 0); @@ -1031,6 +1041,13 @@ dummy_func(void) { sym_set_const(callable, (PyObject *)&PyType_Type); } + op(_GUARD_CALLABLE_TUPLE_1, (callable, unused, unused -- callable, unused, unused)) { + if (sym_get_const(ctx, callable) == (PyObject *)&PyTuple_Type) { + REPLACE_OP(this_instr, _NOP, 0, 0); + } + sym_set_const(callable, (PyObject *)&PyTuple_Type); + } + op(_GUARD_CALLABLE_STR_1, (callable, unused, unused -- callable, unused, unused)) { if (sym_get_const(ctx, callable) == (PyObject *)&PyUnicode_Type) { REPLACE_OP(this_instr, _NOP, 0, 0); |