-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
[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
Conversation
…of the code object (pythonGH-128350)
@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 :) |
It needs a review. |
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_PyCode_InitAddressRange(co, &range); | |
_PyCode_InitAddressRange(code, &range); |
There was a problem hiding this comment.
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.
(Merging now so this can make it into tomorrow's release, please consider the suggested changes for follow-up.) |
Thanks @markshannon for the PR, and @Yhg1s for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @markshannon and @Yhg1s, I could not cleanly backport this to
|
…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)
GH-132268 is a backport of this pull request to the 3.12 branch. |
GH-132268 is a backport of this pull request to the 3.12 branch. |
Manual backport of #128350