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

Emily Rodgers emily at
Fri Nov 6 19:11:47 CET 2009

"Andre Engels" <andreengels at> wrote in message 
news:mailman.2696.1257520404.2807.python-list at
>On Fri, Nov 6, 2009 at 1:12 PM, kj < at> wrote:
>> arr = [None] * 1000000
>> Is this the most efficient way to achieve this result?
> It depends - what do you want to do with it? My first hunch would be
> to use a dictionary instead of a list, then the whole problem
> disappears. If there is a reason you don't want to do that, what is
> it?
> -- 
> André Engels, andreengels at

I second this. It might seem a sensible thing to do in perl, but I can't 
imagine what you would actually want to do it for! Seems like an odd thing 
to want to do! 

More information about the Python-list mailing list