Most efficient way to "pre-grow" a list?

Raymond Hettinger python at
Fri Nov 6 18:39:09 CET 2009

> In fact, one would need to pre-grow the list sufficiently to be
> able to make an assignment like this one.  I.e. one needs the
> equivalent of the second Perl snippet above.
> The best I can come up with is this:
> arr = [None] * 1000000
> Is this the most efficient way to achieve this result?



More information about the Python-list mailing list