The REALLY bad thing about Python lists ..

rturpin at my-deja.com rturpin at my-deja.com
Sun May 14 12:32:29 EDT 2000


I think it is fine that resizable vectors are the
default array implementation. We can just keep in
mind that indexing is fast, growing or shrinking
from the ends is fast, but changing the size in
the middle is slow.

Wait!  Did I say "growing and shrinking from the
ends is fast"??  Alas, that is wrong.  Prepending
is the most expensive insert of all!  The only
insert/delete operations that are fast are those
that change the LAST element.

And why should this be?  It isn't hard to write
resizable vector code that is fast at both ends.
There are lots of times when you want to manipulate
a list from both ends. And Python syntax makes it
easy:

   l[:0] = m          # Prepend list m to l

Double-your-pleasure'ly yrs,
Russell


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list