代码对象¶
代码对象是cpython实现的低级细节。每一个都代表一块尚未绑定到函数中的可执行代码。
-
type PyCodeObject¶
用于描述代码对象的对象的C结构。此类型的字段随时可能更改。
-
PyTypeObject PyCode_Type¶
这是一个
PyTypeObject
代表 Pythoncode
类型。
-
int PyCode_GetNumFree(PyCodeObject *co)¶
返回中的自由变量数 co .
-
PyCodeObject *PyCode_New(int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)¶
- Return value: New reference.
返回新的代码对象。如果需要虚拟代码对象来创建框架,请使用
PyCode_NewEmpty()
相反。调用PyCode_New()
直接将您绑定到精确的Python版本,因为字节码的定义经常更改。
-
PyCodeObject *PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)¶
- Return value: New reference.
类似
PyCode_New()
,但对于仅限位置的参数有一个额外的“posonlyargcount”。3.8 新版功能.
-
PyCodeObject *PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)¶
- Return value: New reference.