Memory pre-allocation for large lists

Avi Kak kak at purdue.edu
Wed Feb 18 00:31:16 EST 2004



Hello:

Is it possible in Python to define an empty list
of a predetermined size?

To illustrate my question further, I can do the
following in Perl

   my @arr = ();
   $#arr = 999;

that wold cause @arr to become an empty array 
of size 1000.  This array could be used to 
store 1000 elements without any further memory
allocation for the array itself.

Can the same be done in Python?

Avi Kak
kak at purdue.edu





More information about the Python-list mailing list