Skip to content

Commit 52ce698

Browse files
committed
Fix review idea
Signed-off-by: Manjusaka <[email protected]>
1 parent 1662b47 commit 52ce698

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Python/optimizer_bytecodes.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,16 @@ dummy_func(void) {
10881088
res = sym_new_type(ctx, &PyLong_Type);
10891089
}
10901090

1091-
op(_GET_LEN, (-- len)) {
1092-
len = sym_new_type(ctx, &PyLong_Type);
1091+
op(_GET_LEN, (obj -- obj, len)) {
1092+
int tuple_length = sym_tuple_length(obj);
1093+
if (tuple_length == -1) {
1094+
// Unknown length
1095+
len = sym_new_type(ctx, &PyLong_Type);
1096+
}
1097+
else {
1098+
assert(tuple_length >= 0);
1099+
len = sym_new_const(ctx, PyLong_FromLong(tuple_length));
1100+
}
10931101
}
10941102

10951103
op(_GUARD_CALLABLE_LEN, (callable, unused, unused -- callable, unused, unused)) {

Python/optimizer_cases.c.h

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)