memory allocation for Python list

bearophileHUGS at bearophileHUGS at
Wed Mar 26 14:32:03 CET 2008

> As I have mentioned, I don't know final length of the list, but
> usually I know a good approximation, for example 400.

There is no reserve()-like method, but this is a fast enough operation
you can do at the beginning:

l = [None] * 400

It may speed up your code, but the final resizing may kill your
performance anyway. You can try it. Just using Psyco is probably


More information about the Python-list mailing list