[Python-Dev] Tuples vs. lists

M.-A. Lemburg mal@lemburg.com
Tue, 05 Feb 2002 11:46:37 +0100

I haven't really followed this thread, but what's all this talk
about lists vs. tuples about ? 

Tuples have a smaller memory footprint, provide faster element 
access, can be cached and are generally a good data type for 
constant data structures. Lists, OTOH, provide more flexibility 
when the size of the object isn't known in advance. They use up 
more memory, are not cacheable and slower on access.

For the BCD stuff Aahz was talking about, I'd suggest to have
a look at either arrays or cStringIO buffers.

Jeremy Hylton wrote:
> Hey, should I change all the tuples in code objects to be lists, too?
> A code object has got things like co_names and co_consts.  They're
> currently implemented as tuples, but they're just homogenous,
> variable-length sequences.  <wink>
> 'course if people modified the lists, they'd caused Python to dump
> core.

I hope I read the <wink> correctly :-)

Marc-Andre Lemburg
CEO eGenix.com Software GmbH
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/