title: Reserve memory for list in Python?
body: <p>When programming in Python, is it possible to reserve memory for a list that will be populated with a known number of items, so that the list will not be reallocated several times while building it?  I've looked through the docs for a Python list type, and have not found anything that seems to do this.  However, this type of list building shows up in a few hotspots of my code, so I want to make it as efficient as possible.</p>
  
  <p>Edit:  Also, does it even make sense to do something like this in a language like Python?  I'm a fairly experienced programmer, but new to Python and still getting a feel for its way of doing things.  Does Python internally allocate <strong>all</strong> objects in separate heap spaces, defeating the purpose of trying to minimize allocations, or are primitives like ints, floats, etc. stored directly in lists?</p>