./python.exe -m timeit -s 'd = {"a": 1}' 'd["a"]'
# 10000000 loops, best of 5: 29.1 nsec per loop
S="
class A: pass
d = A()
d.a = 1
"
./python.exe -m timeit -s $S 'd.a'
# 20000000 loops, best of 5: 17.3 nsec per loop
I think string-only-key dict is very common.
If there is optimisation technique done for attribute access, how difficult it would be to transfer similar benefit to dict object?
I think string-only-key
dictis very common.If there is optimisation technique done for attribute access, how difficult it would be to transfer similar benefit to
dictobject?