Skip to content

[3.13] GH-127953: Make line number lookup O(1) regardless of the size of the code object #129127

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 3 commits into from
Apr 7, 2025

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jan 21, 2025

@Yhg1s
Copy link
Member

Yhg1s commented Apr 2, 2025

@markshannon What's the state of this backport? Should this be considered for 3.13.3 (scheduled next week)? What about 3.12? (There's still time to get it into 3.12 before we stop backporting bugfixes :)

@markshannon
Copy link
Member Author

It needs a review.
Should be good to go otherwise, the original PR seems to be working fine.

for (int i = 0; i < code_len;) {
_Py_CODEUNIT *instr = &_PyCode_CODE(code)[i];
int opcode = instr->op.code;
int base_opcode = _Py_GetBaseOpcode(code, i);
int base_opcode = _Py_GetBaseCodeUnit(code, i).op.code;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int base_opcode = _Py_GetBaseCodeUnit(code, i).op.code;
int base_opcode = _Py_GetBaseOpcode(code, i);

@@ -504,10 +555,12 @@ sanity_check_instrumentation(PyCodeObject *code)
code->_co_monitoring->active_monitors,
active_monitors));
int code_len = (int)Py_SIZE(code);
PyCodeAddressRange range;
_PyCode_InitAddressRange(co, &range);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_PyCode_InitAddressRange(co, &range);
_PyCode_InitAddressRange(code, &range);

Copy link
Member

Choose a reason for hiding this comment

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

This typo is present in main as well, but I figured I'd try building with INSTRUMENT_DEBUG set just the same.

@Yhg1s
Copy link
Member

Yhg1s commented Apr 7, 2025

(Merging now so this can make it into tomorrow's release, please consider the suggested changes for follow-up.)

@Yhg1s Yhg1s merged commit 3f38632 into python:3.13 Apr 7, 2025
39 checks passed
@Yhg1s Yhg1s added the needs backport to 3.12 only security fixes label Apr 7, 2025
@miss-islington-app
Copy link

Thanks @markshannon for the PR, and @Yhg1s for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @markshannon and @Yhg1s, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 3f3863281bb3cd40efc2f1c4bed901457b8cd170 3.12

markshannon added a commit to faster-cpython/cpython that referenced this pull request Apr 8, 2025
…e size of the code object (python#129127)

pythonGH-127953: Make line number lookup O(1) regardless of the size of the code object (pythonGH-128350)
@bedevere-app
Copy link

bedevere-app bot commented Apr 8, 2025

GH-132268 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Apr 8, 2025
@bedevere-app
Copy link

bedevere-app bot commented Apr 8, 2025

GH-132268 is a backport of this pull request to the 3.12 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants