Created
March 9, 2019 16:29
-
-
Save AdamGold/4253cd76d166b1d87d7cf6aedff9f977 to your computer and use it in GitHub Desktop.
This file contains 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
In [25]: dis.dis("t[a] += b") | |
1 0 LOAD_NAME 0 (t) | |
2 LOAD_NAME 1 (a) | |
4 DUP_TOP_TWO | |
6 BINARY_SUBSCR | |
8 LOAD_NAME 2 (b) | |
10 INPLACE_ADD --> (value in t[a]) += b --> succeeds because list is mutable | |
12 ROT_THREE | |
14 STORE_SUBSCR --> Assign t[a] = our list --> Fails, t[a] is immutable. | |
16 LOAD_CONST 0 (None) | |
18 RETURN_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment