lists, performance..

David Eppstein eppstein at ics.uci.edu
Thu Oct 31 12:58:41 EST 2002


In article <m2d6pq8pw6.fsf at python.net>, Michael Hudson <mwh at python.net> 
wrote:

> > i'm worried about how many times would the list resize itself to be able
> > to contain the additional 20elements if i would add them one-by-one
> 
> Standard advice here: don't worry about it now, write your program and
> if you find it goes too slowly, come back and speed up the bits that
> will make the most difference.

In this specific case, appending to lists is constant amortized time 
(and accessing list elements is constant time) so it's likely his fears 
about performance are not well-founded.

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list