Created
May 22, 2014 12:53
-
-
Save avalanchy/09b260ea6f6cf68e8856 to your computer and use it in GitHub Desktop.
Python bool casting
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
| >>> from dis import dis | |
| >>> a = lambda: bool('') | |
| >>> b = lambda: not not '' | |
| >>> dis(a) | |
| 1 0 LOAD_GLOBAL 0 (bool) | |
| 3 LOAD_CONST 1 ('') | |
| 6 CALL_FUNCTION 1 | |
| 9 RETURN_VALUE | |
| >>> dis(b) | |
| 1 0 LOAD_CONST 1 ('') | |
| 3 UNARY_NOT | |
| 4 UNARY_NOT | |
| 5 RETURN_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment