[Python-Dev] Change in evaluation order in new object model

Tim Peters tim.one@home.com
Fri, 2 Nov 2001 13:38:17 -0500


[Michael McLay]
> ...
> The lookup of a member is also faster because it uses a lookup of
> an offset instead of a dictionary lookup.

There's still a dict lookup:  when you do obj.a where a is a __slot__
attribute of obj.__class__, obj.__class__.__dict__['a'] is looked up in
order to get the descriptor for attribute 'a'.  The fixed set of __slot__
attributes leaves a door open for future optimizations, though (e.g., if
Python could *know* obj.__class__ at compile-time, and know that runtime
code won't overwrite the 'a' descriptor in obj.__class__.__dict__, it could
map obj.a directly to its storage offset (from the base of obj) at
compile-time).