tuple.index()
Christoph Zwerschke
cito at online.de
Sat Dec 16 05:01:00 EST 2006
Hendrik van Rooyen wrote:
> From a practical point of view, the only reason to use a tuple instead
> of a list for anything seems to be that you want to use it as a key in a dict...
>
> Otherwise, why bother with these recalcitrant things that you can't
> change or index, or append to or anything that lists allow?
I can imagine (but don't know whether this is actually the case in
CPython) that tuples have some memory and/or performance advantages over
lists, and there could be special optimizations for small (2 or 3
element) tuples because they are used very frequently.
So that would be another practical aspect why a long list of tuples
could be better than a long list of lists - but does anybody know
whether this is even true for CPython?
-- Christoph
More information about the Python-list
mailing list