diff options
author | Amit Lavon <amitlavon1.spam@gmail.com> | 2025-06-07 14:08:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-07 14:08:44 -0700 |
commit | 8fdbbf8b18f1405abe677d0e04874c1c86ccdb4a (patch) | |
tree | d888bec4d3123eab86ddd064eda71300a02ce825 /Python/optimizer_cases.c.h | |
parent | ac9c3431cc5916a795c42b3e2b965233ceffe6f0 (diff) | |
download | cpython-8fdbbf8b18f1405abe677d0e04874c1c86ccdb4a.tar.gz cpython-8fdbbf8b18f1405abe677d0e04874c1c86ccdb4a.zip |
GH-131798: Type-propagate string/list/tuple slices (GH-134671)
Diffstat (limited to 'Python/optimizer_cases.c.h')
-rw-r--r-- | Python/optimizer_cases.c.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 1a2d49973ee..b42f47c75ea 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -568,8 +568,19 @@ } case _BINARY_SLICE: { + JitOptSymbol *container; JitOptSymbol *res; - res = sym_new_not_null(ctx); + container = stack_pointer[-3]; + PyTypeObject *type = sym_get_type(container); + if (type == &PyUnicode_Type || + type == &PyList_Type || + type == &PyTuple_Type) + { + res = sym_new_type(ctx, type); + } + else { + res = sym_new_not_null(ctx); + } stack_pointer[-3] = res; stack_pointer += -2; assert(WITHIN_STACK_BOUNDS()); |