title: Optimising list creation in Python
body: <p>I am creating a list by using</p>
  
  <pre><code>sum_range=list(2**x for x in range(start_range,end_range+1))
  </code></pre>
  
  <p>Here the start_range and the end_range take large values from 0 to about 4 million.</p>
  
  <p>This line of code seems to be the bottle neck. 
  Ultimately I want the sum of all the number in the list sum_range. There can possibly be a better way to do this? </p>
  
  <p><strong>Time take when:-</strong></p>
  
  <p>start_range=188640 
  end_range=197280</p>
  
  <p>The code takes about 6 seconds to run on my system. </p>