List Performance

Maric Michaud maric at aristote.info
Mon Jun 30 11:27:09 CEST 2008


Le Monday 30 June 2008 09:23:46 Peter Otten, vous avez écrit :
> Ampedesign wrote:
> > If I happen to have a list that contains over 50,000 items, will the
> > size of the list severely impact the performance of appending to the
> > list?
>
> No.
>
> $ python -m timeit -n20000 -s"items = []" "items.append(42)"
> 20000 loops, best of 3: 0.554 usec per loop
> $ python -m timeit -n20000 -s"items = [42]*10**6" "items.append(42)"
> 20000 loops, best of 3: 0.529 usec per loop

But it surely could, if the box happens to be out of memory and begin to swap, 
while it's not, of course, an issue with python lists...

-- 
_____________

Maric Michaud



More information about the Python-list mailing list