"Tuples are for heterogeneous data, lists are for homogeneous data."

Erik Max Francis max at alcyone.com
Tue Mar 11 22:16:33 EST 2003


Arthur wrote:

> The subject line is a Guido quote from today's dev list.
> 
> Is the point Guido making performance related, or is it something
> else? I
> have used lists extensively for heterogenous data, and wonder what it
> is I
> am losing by so doing.

Nothing, it's just a style guideline.  I'm aware of no optimizations
that would provide a penalty for not using lists/tuples in this way.

I tend to use tuples for either data that have a fixed number of
elements (like coordinates, if I don't represent them with separate
attributes), or for data that have a fixed number of (or easily found
pattern of) elements but contain heterogeneous data (like the first is
an int, the second is a string, the third is an object of some class).

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Who, my friend, can scale Heaven?
\__/ _The Epic of Gilgamesh_
    EmPy / http://www.alcyone.com/pyos/empy/
 A templating system for Python.




More information about the Python-list mailing list