-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
[3.12] GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-129127) #132268
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
base: 3.12
Are you sure you want to change the base?
Conversation
…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)
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.
_PyFrame_SetStackPointer(frame, stack_pointer); | ||
int original_opcode = _Py_call_instrumentation_line( | ||
tstate, frame, here, prev); | ||
stack_pointer = _PyFrame_GetStackPointer(frame); | ||
if (original_opcode < 0) { | ||
next_instr = here+1; | ||
goto error; | ||
int original_opcode = 0; | ||
if (tstate->tracing) { | ||
PyCodeObject *code = frame->f_code; | ||
int index = (int)(here - _PyCode_CODE(code)); | ||
original_opcode = code->_co_monitoring->lines->data[index*code->_co_monitoring->lines->bytes_per_entry]; | ||
} | ||
next_instr = frame->prev_instr; | ||
if (next_instr != here) { | ||
DISPATCH(); | ||
else { | ||
_PyFrame_SetStackPointer(frame, stack_pointer); | ||
original_opcode = _Py_call_instrumentation_line( | ||
tstate, frame, here, prev); | ||
stack_pointer = _PyFrame_GetStackPointer(frame); | ||
if (original_opcode < 0) { | ||
next_instr = here+1; | ||
goto error; | ||
} | ||
next_instr = frame->prev_instr; | ||
if (next_instr != here) { | ||
DISPATCH(); | ||
} |
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 looks wrong; this isn't present in the original change, but is instead a partial backport of GH-114986
PyCodeAddressRange range; | ||
_PyCode_InitAddressRange(code, &range); | ||
int max_line = code->co_firstlineno + 1; | ||
_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 line appears to be a copy-paste error; it duplicates line 1553 above.
Manual backport of #129127.
This probably isn't getting merged into 3.12 (that's up to @Yhg1s), but I wanted to make available to anyone who wants it in their 3.12