GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)

This commit is contained in:
Mark Shannon 2025-01-21 09:33:23 +00:00 committed by GitHub
parent f7cc7d296c
commit 7239da7559
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 214 additions and 163 deletions

View file

@ -4816,7 +4816,8 @@ dummy_func(
int original_opcode = 0;
if (tstate->tracing) {
PyCodeObject *code = _PyFrame_GetCode(frame);
original_opcode = code->_co_monitoring->lines[(int)(this_instr - _PyFrame_GetBytecode(frame))].original_opcode;
int index = (int)(this_instr - _PyFrame_GetBytecode(frame));
original_opcode = code->_co_monitoring->lines->data[index*code->_co_monitoring->lines->bytes_per_entry];
next_instr = this_instr;
} else {
original_opcode = _Py_call_instrumentation_line(