Memory pre-allocation for large lists

Josiah Carlson jcarlson at nospam.uci.edu
Wed Feb 18 02:21:45 EST 2004


> Can, yes.  But why?  Python uses an allocation mechanism for lists that
> results in constant amortized time; there's really no reason to
> pre-allocate.

It is a bit faster to pre-allocate, and sometimes you know how big the 
sequence is going to be beforehand.

  - Josiah



More information about the Python-list mailing list