Last active
October 19, 2019 10:48
-
-
Save disconnect3d/48075bcb3e5595cc2525c8ac6829cf20 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
In [9]: def foo(): | |
...: return x | |
...: def foofoo(x): | |
...: return x | |
...: def bar(): | |
...: x += 1 | |
...: def foobar(): | |
...: global x | |
...: x += 1 | |
...: | |
...: | |
In [10]: dis.dis(foo) | |
2 0 LOAD_GLOBAL 0 (x) | |
2 RETURN_VALUE | |
In [11]: dis.dis(foofoo) | |
4 0 LOAD_FAST 0 (x) | |
2 RETURN_VALUE | |
In [12]: dis.dis(bar) | |
6 0 LOAD_FAST 0 (x) | |
2 LOAD_CONST 1 (1) | |
4 INPLACE_ADD | |
6 STORE_FAST 0 (x) | |
8 LOAD_CONST 0 (None) | |
10 RETURN_VALUE | |
In [13]: dis.dis(foobar) | |
9 0 LOAD_GLOBAL 0 (x) | |
2 LOAD_CONST 1 (1) | |
4 INPLACE_ADD | |
6 STORE_GLOBAL 0 (x) | |
8 LOAD_CONST 0 (None) | |
10 RETURN_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment