Created
March 11, 2015 08:54
-
-
Save Deepwalker/c52a74c26df0707dd303 to your computer and use it in GitHub Desktop.
dict.update
This file contains hidden or 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
>>> import code | |
>>> import dis | |
>>> def func(): | |
... d = {} | |
... d.update({'a': 2, 'b':3}) | |
... | |
>>> dis.dis(func.__code__) | |
2 0 BUILD_MAP 0 | |
3 STORE_FAST 0 (d) | |
3 6 LOAD_FAST 0 (d) | |
9 LOAD_ATTR 0 (update) | |
12 BUILD_MAP 2 | |
15 LOAD_CONST 1 (2) | |
18 LOAD_CONST 2 ('a') | |
21 STORE_MAP | |
22 LOAD_CONST 3 (3) | |
25 LOAD_CONST 4 ('b') | |
28 STORE_MAP | |
29 CALL_FUNCTION 1 (1 positional, 0 keyword pair) | |
32 POP_TOP | |
33 LOAD_CONST 0 (None) | |
36 RETURN_VALUE | |
>>> def bunc(): | |
... d = {} | |
... d['a'] = 2 | |
... d['b'] = 3 | |
... | |
>>> dis.dis(bunc.__code__) | |
2 0 BUILD_MAP 0 | |
3 STORE_FAST 0 (d) | |
3 6 LOAD_CONST 1 (2) | |
9 LOAD_FAST 0 (d) | |
12 LOAD_CONST 2 ('a') | |
15 STORE_SUBSCR | |
4 16 LOAD_CONST 3 (3) | |
19 LOAD_FAST 0 (d) | |
22 LOAD_CONST 4 ('b') | |
25 STORE_SUBSCR | |
26 LOAD_CONST 0 (None) | |
29 RETURN_VALUE | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment