@@ -224,6 +224,33 @@ Unless using :pep:`523`, you will not need this.
224224
225225 .. versionadded :: 3.11
226226
227+ The allocation-free raw-frame APIs added in Python 3.15 —
228+ :c:func: `PyUnstable_ThreadState_GetCurrentFrame `,
229+ :c:func: `PyUnstable_InterpreterFrame_GetCaller `,
230+ :c:func: `PyUnstable_InterpreterFrame_GetCodeBorrowed `, and
231+ :c:func: `PyUnstable_InterpreterFrame_GetLineChecked ` — are intended for
232+ low-level observability and diagnostic tools that need to inspect the Python
233+ call stack without materializing Python frame objects. Examples include native
234+ profilers, crash reporters, custom allocator hooks, and C callbacks used with
235+ :mod: `sys.monitoring `.
236+
237+ Unlike :c:func: `PyThreadState_GetFrame `, :c:func: `PyFrame_GetBack `,
238+ :c:func: `PyFrame_GetCode `, and :c:func: `PyFrame_GetLineNumber `, these APIs do
239+ not allocate memory, do not create :c:type: `PyFrameObject ` instances, do not
240+ change reference counts, do not set exceptions, do not call Python code, and do
241+ not acquire or release the GIL.
242+
243+ They provide best-effort, read-only access to raw interpreter frames. Returned
244+ frame and code object pointers are borrowed and must not be stored. If frame
245+ state appears invalid or concurrently torn down, these APIs may return ``NULL ``
246+ or ``-1 ``. Freed-memory checks are heuristic and are not guaranteed to detect
247+ all races.
248+
249+ When used from a C callable registered with :mod: `sys.monitoring `, these APIs
250+ can be used to collect additional stack context beyond the code object and
251+ offset supplied to the callback. They do not make Python-level monitoring
252+ callbacks allocation-free or non-reentrant.
253+
227254.. c :function :: PyObject* PyUnstable_InterpreterFrame_GetCode (struct _PyInterpreterFrame *frame);
228255
229256 Return a :term: `strong reference ` to the code object for the frame.
0 commit comments