I think every Python programmer implements this at some point. I think the real reason not to do this is one that as of this writing still hasn't been mentioned yet, which is that when using dot notation, your key names have to fit the Python grammar for identifiers, so you can't have a key "the thing" with a space, or anything else that isn't a Python identifier. So you can't just say "I can access this dictionary w…
Also dot means attribute means less speed.
In [4]: %timeit d['b'] # dict
10000000 loops, best of 3: 42.7 ns per loop
In [6]: %timeit f.b # class using __slots__
The slowest run took 30.10 times longer than the fastest. This could mean that an intermediate result is being cached.
10000000 loops, best of 3: 44 ns per loop
In [9]: %timeit b.b # class using __dict__
10000000 loops, best of 3: 48.1 ns per loop
You're talking <6ns per access; except in the very exceptional case where you know you need this, in Python of all languages, it's an over optimization. The maintainability of having the stupid-simple class vastly outweighs the speed.