aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
authorAmit Lavon <amitlavon1.spam@gmail.com>2025-06-07 14:08:44 -0700
committerGitHub <noreply@github.com>2025-06-07 14:08:44 -0700
commit8fdbbf8b18f1405abe677d0e04874c1c86ccdb4a (patch)
treed888bec4d3123eab86ddd064eda71300a02ce825 /Python/optimizer_cases.c.h
parentac9c3431cc5916a795c42b3e2b965233ceffe6f0 (diff)
downloadcpython-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.h13
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());