the most efficient method of adding elements to the list

K.S.Sreeram sreeram at
Tue Jun 6 06:49:09 CEST 2006

alf wrote:
> Would it be .append()? Does it reallocate te list with each apend?

No append does NOT reallocate for every call. Whenever a reallocation
happens, the newsize is proportional to the older size. So you should
essentially get amortized constant time for every append call.

If you want to add a bunch of items in one call.. you should use the
'extend' method.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Python-list mailing list