diff options
author | Ken Jin <kenjin4096@gmail.com> | 2022-05-03 13:13:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 13:13:13 (GMT) |
commit | 6c7249f2655749a06b4674a17537f844bd54d217 (patch) | |
tree | 15c7131fdf51411d2e8e566347f75e9f0809f508 /Doc/c-api/code.rst | |
parent | 1d4a9a45b7ac8c1c5fecc363c988be59500f1ed7 (diff) | |
download | cpython-6c7249f2655749a06b4674a17537f844bd54d217.zip cpython-6c7249f2655749a06b4674a17537f844bd54d217.tar.gz cpython-6c7249f2655749a06b4674a17537f844bd54d217.tar.bz2 |
gh-92154: Expose PyCode_GetCode in the C API (GH-92168)
Diffstat (limited to 'Doc/c-api/code.rst')
-rw-r--r-- | Doc/c-api/code.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 407d8b4..7915b81 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -76,3 +76,17 @@ bound into a function. information is not available for any particular element. Returns ``1`` if the function succeeds and 0 otherwise. + +.. c:function:: PyObject* PyCode_GetCode(PyCodeObject *co) + + Equivalent to the Python code ``getattr(co, 'co_code')``. + Returns a strong reference to a :c:type:`PyBytesObject` representing the + bytecode in a code object. On error, ``NULL`` is returned and an exception + is raised. + + This ``PyBytesObject`` may be created on-demand by the interpreter and does + not necessarily represent the bytecode actually executed by CPython. The + primary use case for this function is debuggers and profilers. + + .. versionadded:: 3.11 + |