tuples vs lists

Peter Hansen peter at engcorp.com
Tue Sep 16 21:11:39 CEST 2003

Ivan Voras wrote:
> Ok, I gather touples should be smaller & faster as I thought :)

Don't make a decision based on performance.  Use tuples if you
require the immutability, or if you want to follow Guido's "advice" (?)
to treat them as simple unnamed structs.

Use lists any time you want lists of stuff, even if you think you
might benefit by the supposedly higher performance of a tuple.

Anyone reading your code will likely be much happier, and you won't
find yourself getting caught in a bind because you've used an 
immutable tuples where you really should have used a list.


More information about the Python-list mailing list