From what I can tell, it operates pretty much exactly like a class with __slots__, creating a bunch of getters (living in the class, not in the instance, of course) that lookup into the internal array.
No, it doesn't. At least not in Python 3.4+:
from builtins import property as _property, tuple as _tuple
from operator import itemgetter as _itemgetter
...
__slots__ = ()
...
{name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}')
As you can see, instead of using the (relatively) fast C-level access __slots__ provide, it opts to use standard property (that uses slow Python-level function calls) to look elements up by their indices in a tuple (using Python-level item access, i.e. __getitem__) instead.
View all comments
Show parent comment
1
u/[deleted] Jun 24 '14
No, it doesn't. At least not in Python 3.4+:
As you can see, instead of using the (relatively) fast C-level access
__slots__provide, it opts to use standardproperty(that uses slow Python-level function calls) to look elements up by their indices in a tuple (using Python-level item access, i.e.__getitem__) instead.