Created
November 27, 2014 01:53
-
-
Save alexandre/48382e94a527402979d4 to your computer and use it in GitHub Desktop.
not_not and if_else
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
| >>> def not_not(x): | |
| ... return not(not x) | |
| ... | |
| >>> def if_else(x): | |
| ... return True if x else False | |
| ... | |
| >>> import dis | |
| >>> dis.dis(not_not) | |
| 2 0 LOAD_FAST 0 (x) | |
| 3 UNARY_NOT | |
| 4 UNARY_NOT | |
| 5 RETURN_VALUE | |
| >>> dis.dis(if_else) | |
| 2 0 LOAD_FAST 0 (x) | |
| 3 POP_JUMP_IF_FALSE 10 | |
| 6 LOAD_CONST 1 (True) | |
| 9 RETURN_VALUE | |
| >> 10 LOAD_CONST 2 (False) | |
| 13 RETURN_VALUE | |
| >>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment