writing code over several lines
peter at engcorp.com
Tue Oct 21 20:11:30 CEST 2003
Paul Rubin wrote:
> Peter Hansen <peter at engcorp.com> writes:
> > > Tuples probably aren't faster, but they do use less memory.
> > Again, as I recall the past discussions, not significantly so.
> > They still have only four bytes (a pointer) per element, and surely for
> > any tuple or list where one could possibly be concerned about memory
> > consumption the number of elements far outweighs the overhead associated
> > with the structure itself (which is probably on the order of a few bytes
> > anyway).
> Lists allocate memory for extra elements, so list.append doesn't have
> to copy the whole list around every time you call it.
Ah, I see. How much would that consume in, say, the example as given?
Is that a significant amount, enough to be concerned about?
Is there a published algorithm behind this, or is it just some magic
of the Timbot's that would be found only in the source?
More information about the Python-list