Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-131798: Use sym_new_type instead of sym_new_not_null for _BUILD_STRING, _BUILD_SET #132564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 27, 2025
Prev Previous commit
Next Next commit
Set type for string and slice
Signed-off-by: Manjusaka <me@manjusaka.me>
  • Loading branch information
Zheaoli committed Apr 26, 2025
commit 720915d9cb8ffb3565d8d46441d5afa77a4cea38
26 changes: 8 additions & 18 deletions 26 Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,26 +915,16 @@ dummy_func(void) {
res = sym_new_const(ctx, Py_True);
}

op(_BUILD_TUPLE, (values[oparg] -- tup)) {
tup = sym_new_tuple(ctx, oparg, values);
op(_BUILD_STRING, (values[oparg] -- str)) {
str = sym_new_type(ctx, &PyUnicode_Type);
}

op(_BUILD_STRING, (values[oparg] -- str)) {
bool is_const = true;
for (int i = 0; i < oparg; i++) {
if (!sym_is_const(ctx, values[i])) {
is_const = false;
break;
}
}
if (is_const) {
PyObject *val = sym_get_const(ctx, values[0]);
str = sym_new_const(ctx, val);
Py_DecRef(val);
}
else {
str = sym_new_type(ctx, &PyUnicode_Type);
}
op(_BUILD_SLICE, (values[oparg] -- slice)) {
slice = sym_new_type(ctx, &PySlice_Type);
}

op(_BUILD_TUPLE, (values[oparg] -- tup)) {
tup = sym_new_tuple(ctx, oparg, values);
}

op(_UNPACK_SEQUENCE_TWO_TUPLE, (seq -- val1, val0)) {
Expand Down
28 changes: 5 additions & 23 deletions 28 Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.