Skip to content

Instantly share code, notes, and snippets.

@jsocol
Created February 12, 2015 17:57
Show Gist options
  • Select an option

  • Save jsocol/5ca69c9dd5761f55bfd4 to your computer and use it in GitHub Desktop.

Select an option

Save jsocol/5ca69c9dd5761f55bfd4 to your computer and use it in GitHub Desktop.
python is less crazy than it seems
In [8]: def t():
f = ([],)
f[0] += [1]
return f
...:
In [9]: dis.dis(t)
2 0 BUILD_LIST 0
3 BUILD_TUPLE 1
6 STORE_FAST 0 (f)
3 9 LOAD_FAST 0 (f)
12 LOAD_CONST 1 (0)
15 DUP_TOPX 2
18 BINARY_SUBSCR
19 LOAD_CONST 2 (1)
22 BUILD_LIST 1
25 INPLACE_ADD
26 ROT_THREE
27 STORE_SUBSCR
4 28 LOAD_FAST 0 (f)
31 RETURN_VALUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment