Created
May 1, 2018 08:44
-
-
Save cleac/d0212955a9ce3885ac7667db00a2faf0 to your computer and use it in GitHub Desktop.
"import dis" article gist 5
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 string_generation_function(argument): | |
... return 'hello, {}'.format(argument) | |
... | |
>>> def function_for_dis(argument): | |
... return [[string_generation_function('world')]] * 10 | |
... | |
>>> dis.dis(function_for_dis) | |
2 0 LOAD_GLOBAL 0 (string_generation_function) | |
3 LOAD_CONST 1 ('world') | |
6 CALL_FUNCTION 1 | |
9 BUILD_LIST 1 | |
12 BUILD_LIST 1 | |
15 LOAD_CONST 2 (10) | |
18 BINARY_MULTIPLY | |
19 RETURN_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment