What’s the difference between dict() and {}?
>>> def f(): … return {‘a’ : 1, ‘b’ : 2} … >>> def g(): … return dict(a=1, b=2) … >>> g() {‘a’: 1, ‘b’: 2} >>> f() {‘a’: 1, ‘b’: 2} >>> import dis >>> dis.dis(f) 2 0 BUILD_MAP 0 3 DUP_TOP 4 LOAD_CONST 1 (‘a’) 7 LOAD_CONST 2 (1) 10 ROT_THREE 11 STORE_SUBSCR … Read more