diff options
| author | Mark Shannon <mark@hotpy.org> | 2025-04-07 18:15:02 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 18:15:02 (GMT) |
| commit | 3f3863281bb3cd40efc2f1c4bed901457b8cd170 (patch) | |
| tree | b866be1366c73792f5a8901e096a637a738dc093 /Objects/codeobject.c | |
| parent | 1fcf409acef8a7a039353cf11a0bbb24ca6722f8 (diff) | |
| download | cpython-3f3863281bb3cd40efc2f1c4bed901457b8cd170.zip cpython-3f3863281bb3cd40efc2f1c4bed901457b8cd170.tar.gz cpython-3f3863281bb3cd40efc2f1c4bed901457b8cd170.tar.bz2 | |
[3.13] GH-127953: Make line number lookup O(1) regardless of the size of the code object (#129127)
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)
Diffstat (limited to 'Objects/codeobject.c')
| -rw-r--r-- | Objects/codeobject.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 470ed51..bfa679f 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -987,6 +987,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); |
