https://github.com/python/cpython/commit/1f9c28d2457a914c092109db6a0283944a7be98b commit: 1f9c28d2457a914c092109db6a0283944a7be98b branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity <[email protected]> date: 2026-10-23T17:53:06Z summary:
[3.14] gh-156725: Document O(N) behavior of `PyCode_Addr2Line` (GH-156736) (GH-160454) (cherry picked from commit 8d119208074fef0f652f14f78612b044dd218c4f) Co-authored-by: Himesh Rupchandani <[email protected]> files: M Doc/c-api/code.rst diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index db2a4ba9194312..b8a13bf0a86768 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -96,11 +96,12 @@ bound into a function. .. c:function:: int PyCode_Addr2Line(PyCodeObject *co, int byte_offset) - Return the line number of the instruction that occurs on or before ``byte_offset`` and ends after it. - If you just need the line number of a frame, use :c:func:`PyFrame_GetLineNumber` instead. + Return the line number of the instruction that occurs on or before + ``byte_offset`` and ends after it. This may be ``O(N)`` in the number of + instructions in the code object, so it is not performant for iterating over + all the line numbers in a code object. - For efficiently iterating over the line numbers in a code object, use :pep:`the API described in PEP 626 - <0626#out-of-process-debuggers-and-profilers>`. + If you just need the line number of a frame, use :c:func:`PyFrame_GetLineNumber` instead. .. c:function:: int PyCode_Addr2Location(PyObject *co, int byte_offset, int *start_line, int *start_column, int *end_line, int *end_column) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
