Skip to content

Conversation

@y1yang0
Copy link

@y1yang0 y1yang0 commented Jan 22, 2026

@python-cla-bot
Copy link

python-cla-bot bot commented Jan 22, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jan 22, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Jan 22, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@y1yang0
Copy link
Author

y1yang0 commented Jan 22, 2026

I'm not sure if this patch requires a new news item. I'll let the reviewer decide.

@aisk aisk added the skip news label Jan 22, 2026
@aisk
Copy link
Contributor

aisk commented Jan 22, 2026

Hi, I think there have been some CI changes in the main branch, and this branch is not up to date, which is causing the CI to fail. Could you please sync this branch with main (you can simply click the “Update branch” button above, and please avoid rebasing and force push in the CPython repo) to make the CI pass?

_, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
print(uops)

This comment was marked as resolved.

@y1yang0
Copy link
Author

y1yang0 commented Jan 23, 2026

The tests failed, but it seems unrelated to this patch. I can't find a way to retry the failed checks. Could a reviewer please help trigger a retry? Thanks.

Comment on lines 1422 to 1437
Py_ssize_t length = sym_tuple_length(arg);
if (length >= 0) {
temp = PyLong_FromSsize_t(length);
if (temp == NULL) {
goto error;
}
}
else if (sym_is_const(ctx, arg)) {
PyObject *const_val = sym_get_const(ctx, arg);
if (const_val != NULL && PyUnicode_CheckExact(const_val)) {
temp = PyLong_FromSsize_t(PyUnicode_GET_LENGTH(const_val));
if (temp == NULL) {
goto error;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can optimize the logic here:

        if (length < 0 && sym_is_const(ctx, arg)) {
            PyObject *const_val = sym_get_const(ctx, arg);
            if (const_val != NULL && PyUnicode_CheckExact(const_val)) {
                length = PyUnicode_GET_LENGTH(const_val);
            }
        }
        if (length >= 0) {
            PyObject *temp = PyLong_FromSsize_t(length);
            if (temp == NULL) {
                goto error;
            }
            if (_Py_IsImmortal(temp)) {
                ADD_OP(_SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
                        0, (uintptr_t)temp);
            }
            res = sym_new_const(ctx, temp);
            Py_DECREF(temp);
        }

Comment on lines 1431 to 1432
if (const_val != NULL && PyUnicode_CheckExact(const_val)) {
temp = PyLong_FromSsize_t(PyUnicode_GET_LENGTH(const_val));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also deal with the PyBytes_CheckExact + PyBytes_GET_SIZE?

@Fidget-Spinner
Copy link
Member

Sorry I'm busy right now, and will review this over the weekend. Thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants