python dis

不羁岁月 提交于 2020-02-29 04:32:01

day03$ cat declare.py

i = 1

l = []

d = {}

s = 'str'
day03$ cat declare.txt
day03$ vi declare.py
day03$ ipython
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
Type "copyright", "credits" or "license" for more information.
In [1]: s = open('de')
%%debug     %debug      declare.py  def         del         delattr     

In [1]: s = open('declare.py').read()
In [2]: co = compile(s, 'declare.py', 'exec')
In [3]: import dis
In [4]: dis.dis(co)
  2           0 LOAD_CONST               0 (1)
              3 STORE_NAME               0 (i)

  4           6 BUILD_LIST               0
              9 STORE_NAME               1 (l)

  6          12 BUILD_MAP                0
             15 STORE_NAME               2 (d)

  8          18 LOAD_CONST               1 ('str')
             21 STORE_NAME               3 (s)
             24 LOAD_CONST               2 (None)
             27 RETURN_VALUE        

In [5]:

day03$

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!