mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)
This commit is contained in:
parent
f7cc7d296c
commit
7239da7559
6 changed files with 214 additions and 163 deletions
|
|
@ -979,6 +979,9 @@ PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
|||
if (addrq < 0) {
|
||||
return co->co_firstlineno;
|
||||
}
|
||||
if (co->_co_monitoring && co->_co_monitoring->lines) {
|
||||
return _Py_Instrumentation_GetLine(co, addrq/sizeof(_Py_CODEUNIT));
|
||||
}
|
||||
assert(addrq >= 0 && addrq < _PyCode_NBYTES(co));
|
||||
PyCodeAddressRange bounds;
|
||||
_PyCode_InitAddressRange(co, &bounds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue