反射¶
-
PyObject *PyEval_GetBuiltins(void)¶
- 返回值:借入的引用。 属于 稳定 ABI.
自 3.13 版本弃用: Use
PyEval_GetFrameBuiltins()
instead.返回当前执行帧中内置函数的字典,如果当前没有帧正在执行,则返回线程状态的解释器。
-
PyObject *PyEval_GetLocals(void)¶
- 返回值:借入的引用。 属于 稳定 ABI.
自 3.13 版本弃用: Use either
PyEval_GetFrameLocals()
to obtain the same behaviour as callinglocals()
in Python code, or else callPyFrame_GetLocals()
on the result ofPyEval_GetFrame()
to access thef_locals
attribute of the currently executing frame.Return a mapping providing access to the local variables in the current execution frame, or
NULL
if no frame is currently executing.Refer to
locals()
for details of the mapping returned at different scopes.As this function returns a borrowed reference, the dictionary returned for optimized scopes is cached on the frame object and will remain alive as long as the frame object does. Unlike
PyEval_GetFrameLocals()
andlocals()
, subsequent calls to this function in the same frame will update the contents of the cached dictionary to reflect changes in the state of the local variables rather than returning a new snapshot.在 3.13 版本发生变更: As part of PEP 667,
PyFrame_GetLocals()
,locals()
, andFrameType.f_locals
no longer make use of the shared cache dictionary. Refer to the What's New entry for additional details.
-
PyObject *PyEval_GetGlobals(void)¶
- 返回值:借入的引用。 属于 稳定 ABI.
自 3.13 版本弃用: Use
PyEval_GetFrameGlobals()
instead.返回当前执行帧中全局变量的字典,如果没有当前执行的帧则返回
NULL
。
-
PyFrameObject *PyEval_GetFrame(void)¶
- 返回值:借入的引用。 属于 稳定 ABI.
返回当前线程状态的帧,如果没有当前执行的帧则返回
NULL
。另请参阅
PyThreadState_GetFrame()
。
-
PyObject *PyEval_GetFrameBuiltins(void)¶
- 返回值:新的引用。 属于 稳定 ABI 自 3.13 版起.
返回当前执行帧中内置函数的字典,如果当前没有帧正在执行,则返回线程状态的解释器。
Added in version 3.13.
-
PyObject *PyEval_GetFrameLocals(void)¶
- 返回值:新的引用。 属于 稳定 ABI 自 3.13 版起.
Return a dictionary of the local variables in the current execution frame, or
NULL
if no frame is currently executing. Equivalent to callinglocals()
in Python code.To access
f_locals
on the current frame without making an independent snapshot in optimized scopes, callPyFrame_GetLocals()
on the result ofPyEval_GetFrame()
.Added in version 3.13.
-
PyObject *PyEval_GetFrameGlobals(void)¶
- 返回值:新的引用。 属于 稳定 ABI 自 3.13 版起.
Return a dictionary of the global variables in the current execution frame, or
NULL
if no frame is currently executing. Equivalent to callingglobals()
in Python code.Added in version 3.13.
-
const char *PyEval_GetFuncName(PyObject *func)¶
- 属于 稳定 ABI.
如果 func 是函数、类或实例对象,则返回它的名称,否则返回 func 的类型的名称。
-
const char *PyEval_GetFuncDesc(PyObject *func)¶
- 属于 稳定 ABI.
根据 func 的类型返回描述字符串。 返回值包括函数和方法的 "()", " constructor", " instance" 和 " object"。 与
PyEval_GetFuncName()
的结果连接,结果将是 func 的描述。