Skip to content

Commit 58384c6

Browse files
authored
Document PyCode_Addr2Line function. (GH-25111)
* Document PyCode_Addr2Line function. * Clarify when to use PEP 626 line iterators.
1 parent bec8c78 commit 58384c6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/c-api/code.rst

+8
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,11 @@ bound into a function.
5151
Return a new empty code object with the specified filename,
5252
function name, and first line number. It is illegal to
5353
:func:`exec` or :func:`eval` the resulting code object.
54+
55+
.. c:function:: int PyCode_Addr2Line(PyCodeObject *co, int byte_offset)
56+
57+
Return the line number of the instruction that occurs on or before ``byte_offset`` and ends after it.
58+
If you just need the line number of a frame, use :c:func:`PyFrame_GetLineNumber` instead.
59+
60+
For efficiently iterating over the line numbers in a code object, use `the API described in PEP 626
61+
<https://www.python.org/dev/peps/pep-0626/#out-of-process-debuggers-and-profilers>`_.

0 commit comments

Comments
 (0)