Python2.7.10上的PyCodeObject

1、code结构:

class code(object)
 |  code(argcount, nlocals, stacksize, flags, codestring, constants, names,
 |        varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])
 |  
 |  Create a code object.  Not for the faint of heart.
 |  
 |  Methods defined here:
 |  
 |  __cmp__(...)
 |      x.__cmp__(y) <==> cmp(x,y)
 |  
 |  __eq__(...)
 |      x.__eq__(y) <==> x==y
 |  
 |  __ge__(...)
 |      x.__ge__(y) <==> x>=y
 |  
 |  __getattribute__(...)
 |      x.__getattribute__('name') <==> x.name
 |  
 |  __gt__(...)
 |      x.__gt__(y) <==> x>y
 |  
 |  __hash__(...)
 |      x.__hash__() <==> hash(x)
 |  
 |  __le__(...)
 |      x.__le__(y) <==> x<=y
 |  
 |  __lt__(...)
 |      x.__lt__(y) <==> x<y
 |  
 |  __ne__(...)
 |      x.__ne__(y) <==> x!=y
 |  
 |  __repr__(...)
 |      x.__repr__() <==> repr(x)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  co_argcount        #CodeBlock中位置参数的个数,即:在调用时出现的位置参数的个数(不包含可变参数*varargs)
 |  
 |  co_cellvars           #(cellvars:被内层代码所约束的变量):在本代码段中被赋值,且被内层代码段(嵌套的函数中)引用的变量
 |  
 |  co_code               #Code Block编译所得的字节码指令序列
 |  
 |  co_consts             #Code Block中的所有常量的元组
 |  
 |  co_filename          #Code Block所对应的的.py文件的完整路径
 |  
 |  co_firstlineno        #Code Block在对应的.py文件中的起始行
 |  
 |  co_flags                 #不知道什么意思
 |  
 |  co_freevars            #(freevars:自由变量):在本代码段中被引用,在外层代码段中被赋值的变量
 |  
 |  co_lnotab              #字节码指令与.pyc文件中的source code行号的对于关系,不明白
 |  
 |  co_name                #Code Block的名字,,通常是函数名或类名
 |  
 |  co_names               #Code Block中的所有符号(名字)的元组,不懂
 |  
 |  co_nlocals              #Code Block中的所有局部变量的个数,包括code block的参数(co_argcount+co_kwonlyargcount+可变参数个数)+code block内的局部变量
 |  
 |  co_stacksize            #执行该段Code Block需要的栈空间数,怎么看?
 |  
 |  co_varnames          #在本代码段中被赋值,但没有被内层代码段引用的变量.(内嵌的函数名也算。不包含内嵌函数中的局部变量)
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __new__ = <built-in method __new__ of type object>

 |      T.__new__(S, ...) -> a new object with type S, a subtype of T


本地实例:




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值