title: Pre-allocate memory for a dictionary?
body: <p>In python 3.4, I am trying to populate a dictionary in a large loop to allocate 30000 * 1000 double numbers to it. I would like to allocate memory for the dictionary beforehand so that I can reduce the performance overhead caused by allocating memory in each iteration. </p>
  
  <p>Also, how to check the limit of memory size that is allowed to allocate to a dictionary (and list) in python?  For example, if it only allows 50MB, I will try to avoid overflow. This may depends on operating systems and others but I would like to have an idea about how to maximize performance.</p>
  
  <p>I can use </p>
  
  <pre><code>ll = [None] * 1000
  </code></pre>
  
  <p>to allocate memory for a list.</p>
  
  <p>Is there a similar way to do for a dictionary ? </p>
  
  <pre><code>d = {None} * 1000 ? 
  or 
  d = {None: None} * 1000 ? 
  </code></pre>
  
  <p>thanks</p>