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

Andre Engels andreengels at
Sat Nov 7 20:33:29 CET 2009

On Sat, Nov 7, 2009 at 8:25 PM, Luis Alberto Zarrabeitia Gomez
<kyrie at> wrote:
> Quoting Bruno Desthuilliers <bdesth.quelquechose at>:
>> > Another situation where one may want to do this is if one needs to
>> > initialize a non-sparse array in a non-sequential order,
>> Then use a dict.
> Ok, he has a dict.
> Now what? He needs a non-sparse array.

Let d be your dict.

Call the zeroeth place in your array d[0], the first d[1], the 10000th

André Engels, andreengels at

More information about the Python-list mailing list