Reflection

PyObject*PyEval_GetBuiltins(void)
Return value: Borrowed reference. Part of theStable ABI.

Deprecated since version 3.13:UsePyEval_GetFrameBuiltins() instead.

Return a dictionary of the builtins in the current execution frame,or the interpreter of the thread state if no frame is currently executing.

PyObject*PyEval_GetLocals(void)
Return value: Borrowed reference. Part of theStable ABI.

Deprecated since version 3.13:Use eitherPyEval_GetFrameLocals() to obtain the same behaviour as callinglocals() in Python code, or else callPyFrame_GetLocals() on the resultofPyEval_GetFrame() to access thef_locals attribute of thecurrently executing frame.

Return a mapping providing access to the local variables in the current execution frame,orNULL if no frame is currently executing.

Refer tolocals() for details of the mapping returned at different scopes.

As this function returns aborrowed reference, the dictionary returned foroptimized scopes is cached on the frame object and will remainalive as long as the frame object does. UnlikePyEval_GetFrameLocals() andlocals(), subsequent calls to this function in the same frame will update thecontents of the cached dictionary to reflect changes in the state of the local variablesrather than returning a new snapshot.

Changed in version 3.13:As part ofPEP 667,PyFrame_GetLocals(),locals(), andFrameType.f_locals no longer make use of the shared cachedictionary. Refer to theWhat’s New entry foradditional details.

PyObject*PyEval_GetGlobals(void)
Return value: Borrowed reference. Part of theStable ABI.

Deprecated since version 3.13:UsePyEval_GetFrameGlobals() instead.

Return a dictionary of the global variables in the current execution frame,orNULL if no frame is currently executing.

PyFrameObject*PyEval_GetFrame(void)
Return value: Borrowed reference. Part of theStable ABI.

Return the current thread state’s frame, which isNULL if no frame iscurrently executing.

See alsoPyThreadState_GetFrame().

PyObject*PyEval_GetFrameBuiltins(void)
Return value: New reference. Part of theStable ABI since version 3.13.

Return a dictionary of the builtins in the current execution frame,or the interpreter of the thread state if no frame is currently executing.

Added in version 3.13.

PyObject*PyEval_GetFrameLocals(void)
Return value: New reference. Part of theStable ABI since version 3.13.

Return a dictionary of the local variables in the current execution frame,orNULL if no frame is currently executing. Equivalent to callinglocals() in Python code.

To accessf_locals on the current frame without making an independentsnapshot inoptimized scopes, callPyFrame_GetLocals()on the result ofPyEval_GetFrame().

Added in version 3.13.

PyObject*PyEval_GetFrameGlobals(void)
Return value: New reference. Part of theStable ABI since version 3.13.

Return a dictionary of the global variables in the current execution frame,orNULL if no frame is currently executing. Equivalent to callingglobals() in Python code.

Added in version 3.13.

constchar*PyEval_GetFuncName(PyObject*func)
Part of theStable ABI.

Return the name offunc if it is a function, class or instance object, else thename offuncs type.

constchar*PyEval_GetFuncDesc(PyObject*func)
Part of theStable ABI.

Return a description string, depending on the type offunc.Return values include “()” for functions and methods, “ constructor”,“ instance”, and “ object”. Concatenated with the result ofPyEval_GetFuncName(), the result will be a description offunc.