Created
May 8, 2015 11:23
Revisions
-
dcrosta created this gist
May 8, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ >>> def foo(a, b, c): ... if a: ... return b ... return c ... >>> dis.dis(foo) 2 0 LOAD_FAST 0 (a) 3 POP_JUMP_IF_FALSE 10 3 6 LOAD_FAST 1 (b) 9 RETURN_VALUE 4 >> 10 LOAD_FAST 2 (c) 13 RETURN_VALUE >>> def foo(a, b, c): ... if a: ... return b ... else: ... return c ... >>> dis.dis(foo) 2 0 LOAD_FAST 0 (a) 3 POP_JUMP_IF_FALSE 10 3 6 LOAD_FAST 1 (b) 9 RETURN_VALUE 5 >> 10 LOAD_FAST 2 (c) 13 RETURN_VALUE 14 LOAD_CONST 0 (None) # Note that control will never reach here 17 RETURN_VALUE # so even though there's more bytecode, it # won't impact run-time performance