Created
May 1, 2018 08:38
-
-
Save cleac/f4db16d2ff97d8eb45ceffc09ff9df61 to your computer and use it in GitHub Desktop.
"import dis" article gist 3
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(): | |
... return [[string_generation_function('world')] for _ in range(10)] | |
... | |
>>> dis.dis(function_for_dis) | |
2 0 BUILD_LIST 0 | |
3 LOAD_GLOBAL 0 (range) | |
6 LOAD_CONST 1 (10) | |
9 CALL_FUNCTION 1 | |
12 GET_ITER | |
>> 13 FOR_ITER 21 (to 37) | |
16 STORE_FAST 0 (_) | |
19 LOAD_GLOBAL 1 (string_generation_function) | |
22 LOAD_CONST 2 ('world') | |
25 CALL_FUNCTION 1 | |
28 BUILD_LIST 1 | |
31 LIST_APPEND 2 | |
34 JUMP_ABSOLUTE 13 | |
>> 37 RETURN_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment