typedef struct {
PyObject_HEAD
int co_argcount; /* 位置参数个数 */
int co_nlocals; /* 局部变量个数 */
int co_stacksize; /* 栈大小 */
int co_flags;
PyObject *co_code; /* 字节码指令序列 */
PyObject *co_consts; /* 所有常量集合 */
PyObject *co_names; /* 所有符号名称集合 */
PyObject *co_varnames; /* 局部变量名称集合 */
PyObject *co_freevars; /* 闭包用的的变量名集合 */
PyObject *co_cellvars; /* 内部嵌套函数引用的变量名集合 */
/* The rest doesn't count for hash/cmp */
PyObject *co_filename; /* 代码所在文件名 */
PyObject *co_name; /* 模块名|函数名|类名 */
int co_firstlineno; /* 代码块在文件中的起始行号 */
PyObject *co_lnotab; /* 字节码指令和行号的对应关系 */
void *co_zombieframe; /* for optimization only (see frameobject.c) */
} PyCodeObject;
typedef struct {
PyObject_HEAD
int co_argcount; /* 位置参数个数 */
int co_nlocals; /* 局部变量个数 */
int co_stacksize; /* 栈大小 */
int co_flags;
PyObject *co_code; /* 字节码指令序列 */
PyObject *co_consts; /* 所有常量集合 */
PyObject *co_names; /* 所有符号名称集合 */
PyObject *co_varnames; /* 局部变量名称集合 */
PyObject *co_freevars; /* 闭包用的的变量名集合 */
PyObject *co_cellvars; /* 内部嵌套函数引用的变量名集合 */
/* The rest doesn't count for hash/cmp */
PyObject *co_filename; /* 代码所在文件名 */
PyObject *co_name; /* 模块名|函数名|类名 */
int co_firstlineno; /* 代码块在文件中的起始行号 */
PyObject *co_lnotab; /* 字节码指令和行号的对应关系 */
void *co_zombieframe; /* for optimization only (see frameobject.c) */
} PyCodeObject;
s = ”hello” def func(): print s func() s = ”hello” def func(): print s func()
co.co_argcount 0 co.co_nlocals 0 co.co_names (‘s', 'func') co.co_varnames (‘s', 'func') co.co_consts (‘hello', <code object func at 0x2aaeeec57110, file ”test.py”, line 3>, None) co.co_code 'd\x00\x00Z\x00\x00d\x01\x00\x84\x00\x00Z\x01\x00e\x01\x00\x83\x00\x00\x01d\x02\x00S' co.co_argcount 0 co.co_nlocals 0 co.co_names (‘s', 'func') co.co_varnames (‘s', 'func') co.co_consts (‘hello', <code object func at 0x2aaeeec57110, file ”test.py”, line 3>, None) co.co_code 'd\x00\x00Z\x00\x00d\x01\x00\x84\x00\x00Z\x01\x00e\x01\x00\x83\x00\x00\x01d\x02\x00S'
func.co_argcount 0 func.co_nlocals 0 func.co_names (‘s',) func.co_varnames () func.co_consts (None,) func.co_code ‘t\x00\x00GHd\x00\x00S' func.co_argcount 0 func.co_nlocals 0 func.co_names (‘s',) func.co_varnames () func.co_consts (None,) func.co_code ‘t\x00\x00GHd\x00\x00S'
const char *s = “hello”;
void func() {
printf(“%s\n”, s);
}
int main() {
func();
return 0;
}
const char *s = “hello”;
void func() {
printf(“%s\n”, s);
}
int main() {
func();
return 0;
}
typedef struct _frame {
PyObject_VAR_HEAD
struct _frame *f_back; /* 调用者的帧 */
PyCodeObject *f_code; /* 帧对应的字节码对象 */
PyObject *f_builtins; /* 内置名字空间 */
PyObject *f_globals; /* 全局名字空间 */
PyObject *f_locals; /* 本地名字空间 */
PyObject **f_valuestack; /* 运行时栈底 */
PyObject **f_stacktop; /* 运行时栈顶 */
…….
}
typedef struct _frame {
PyObject_VAR_HEAD
struct _frame *f_back; /* 调用者的帧 */
PyCodeObject *f_code; /* 帧对应的字节码对象 */
PyObject *f_builtins; /* 内置名字空间 */
PyObject *f_globals; /* 全局名字空间 */
PyObject *f_locals; /* 本地名字空间 */
PyObject **f_valuestack; /* 运行时栈底 */
PyObject **f_stacktop; /* 运行时栈顶 */
…….
}
co.co_names (‘s', 'func') co.co_consts (‘hello', <code object func at 0x2aaeeec57110, file ”test.py”, line 3>, None) co.co_names (‘s', 'func') co.co_consts (‘hello', <code object func at 0x2aaeeec57110, file ”test.py”, line 3>, None)
func.co_names (‘s',) func.co_consts (None,) func.co_names (‘s',) func.co_consts (None,)
def func(): import sys frame = sys._getframe() print frame.f_locals print frame.f_globals print frame.f_back.f_locals #你可以打印frame的各个域 print s
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有