Skip to content

Instantly share code, notes, and snippets.

@akihironitta
Created October 24, 2020 10:11
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 akihironitta/2a45b095310643c25fb8cb32ddd00844 to your computer and use it in GitHub Desktop.
Save akihironitta/2a45b095310643c25fb8cb32ddd00844 to your computer and use it in GitHub Desktop.
import dis
def func1():
return {"x": 0, "y": 1}
def func2():
return dict(x=0, y=1)
dis.dis(func1)
dis.dis(func2)
# Output:
# --------------------------------------------------------
# 4 0 LOAD_CONST 1 (0)
# 2 LOAD_CONST 2 (1)
# 4 LOAD_CONST 3 (('x', 'y'))
# 6 BUILD_CONST_KEY_MAP 2
# 8 RETURN_VALUE
# 7 0 LOAD_GLOBAL 0 (dict)
# 2 LOAD_CONST 1 (0)
# 4 LOAD_CONST 2 (1)
# 6 LOAD_CONST 3 (('x', 'y'))
# 8 CALL_FUNCTION_KW 2
# 10 RETURN_VALUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment