Tim Peters wrote: > > [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). That'd be cool :-) Say, would it also be possible to use __slots__ for methods ? Or even make all methods defined in the class automagically become __slots__ members ? (As I understood your explanations, __slots__ would not interfere with class attributes, only instance attributes, so this should be possible, right ?) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4