Created
May 1, 2013 04:02
-
-
Save ashwin/5493670 to your computer and use it in GitHub Desktop.
Disassembling a Python method to its bytecode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat foo.py | |
def bar(): | |
a = 10 | |
b = 2 | |
c = a + b | |
$ python | |
>>> import dis | |
>>> import foo | |
>>> dis.dis(foo.bar) | |
2 0 LOAD_CONST 1 (10) | |
3 STORE_FAST 0 (a) | |
3 6 LOAD_CONST 2 (2) | |
9 STORE_FAST 1 (b) | |
4 12 LOAD_FAST 0 (a) | |
15 LOAD_FAST 1 (b) | |
18 BINARY_ADD | |
19 STORE_FAST 2 (c) | |
22 LOAD_CONST 0 (None) | |
25 RETURN_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment