Skip to content

Instantly share code, notes, and snippets.

@EricIO
Created January 24, 2016 11:30
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 EricIO/289c8d01ba14f594277a to your computer and use it in GitHub Desktop.
Save EricIO/289c8d01ba14f594277a to your computer and use it in GitHub Desktop.
unpacking
>>> def f1():
... a,b = 1,2
...
>>> import dis
>>> def f2():
... a,b = [1,2]
...
>>> dis.dis(f1)
2 0 LOAD_CONST 3 ((1, 2))
3 UNPACK_SEQUENCE 2
6 STORE_FAST 0 (a)
9 STORE_FAST 1 (b)
12 LOAD_CONST 0 (None)
15 RETURN_VALUE
>>> dis.dis(f2)
2 0 LOAD_CONST 1 (1)
3 LOAD_CONST 2 (2)
6 ROT_TWO
7 STORE_FAST 0 (a)
10 STORE_FAST 1 (b)
13 LOAD_CONST 0 (None)
16 RETURN_VALUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment