Skip to content

Instantly share code, notes, and snippets.

@cleac
Created May 1, 2018 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleac/d0212955a9ce3885ac7667db00a2faf0 to your computer and use it in GitHub Desktop.
Save cleac/d0212955a9ce3885ac7667db00a2faf0 to your computer and use it in GitHub Desktop.
"import dis" article gist 5
>>> 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