Memory pre-allocation for large lists
Paul Prescod
paul at prescod.net
Wed Feb 18 13:31:52 EST 2004
Aahz wrote:
> ...
> 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.
What if you just want to use index assignment without worrying about
indexing past the part of the list that hasn't been allocated yet?
Nevertheless, your question is legitimate. You seldom have to
pre-allocate lists in Python.
Paul Prescod
More information about the Python-list
mailing list