[Python-Dev] Py2.6 ideas
Phillip J. Eby
pje at telecommunity.com
Fri Feb 16 17:41:51 CET 2007
At 01:38 PM 2/16/2007 +0100, Martin v. Löwis wrote:
>Nick Coghlan schrieb:
> > However, another aspect that occurred to me is that inheriting from
> > tuple has significant practical benefits in terms of speed and memory
> > consumption, at which point it doesn't seem worthwhile to *remove* the
> > indexing capability.
>
>I'm not so sure that inheriting from tuple, and giving it named fields,
>has significant speed and memory benefits. In particular for the memory
>benefits, you can use __slots__ to achieve the same effects, and more
>efficiently so (because it you don't store the tuple length). As for
>speed, I would have to see measurements to be convinced it is faster.
For an otherwise-pure Python implementation, the performance benefit of
inheriting from a tuple is in having ready-made C implementations of
hashing and comparison.
More information about the Python-Dev
mailing list