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 a14d5c0..4f96140 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -855,6 +855,16 @@ dummy_func(void) { } } + op(_CALL_STR_1, (unused, unused, arg -- res)) { + if (sym_matches_type(arg, &PyUnicode_Type)) { + // e.g. str('foo') or str(foo) where foo is known to be a string + res = arg; + } + else { + res = sym_new_type(ctx, &PyUnicode_Type); + } + } + op(_GUARD_IS_TRUE_POP, (flag -- )) { if (sym_is_const(ctx, flag)) { PyObject *value = sym_get_const(ctx, flag); @@ -1021,6 +1031,13 @@ dummy_func(void) { sym_set_const(callable, (PyObject *)&PyType_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); + } + sym_set_const(callable, (PyObject *)&PyUnicode_Type); + } + // END BYTECODES // } |