"Tuples are for heterogeneous data, lists are for homogeneous data."
Tim Peters
tim.one at comcast.net
Tue Mar 11 22:11:01 EST 2003
[Arthur]
> The subject line is a Guido quote from today's dev list.
>
> Is the point Guido making performance related, or is it something else?
Something else. It's a rule of thumb Guido takes too seriously on occasion,
except when it's convenient to ignore it in his own code <wink>.
> I have used lists extensively for heterogenous data, and wonder what it
> is I am losing by so doing.
Beyond the possibility of using them as dict keys, nothing objective I know
of. I also use tuples extensively for homogeneous data, when there are so
many of 'em that memory footprint is a concern (a tuple of len N consumes
less memory than a list of len N containing the same objects, because a list
object contains extra stuff to cater to the *possibility* that the list may
grow or shrink later; a tuple object doesn't have to worry about that).
More information about the Python-list
mailing list