title: More efficient way to calculate standard deviation of a large list in Python
body: <p>Hello I am trying to calculate a bunch of standard deviations of a list about 20,000 values long. Here is an example of my code:</p>
  
  <pre><code>from statistics import stdev
  
  def main():
      a = [x for x in range(0,20000)]
      b = []
  
      for x in range(2, len(a) + 2):
          b.append(stdev(a[:x]))
  
      print(b)
  
  main()
  </code></pre>
  
  <p>This method is extremely slow and I am trying to figure out a way to make it more efficient. Any help is appreciated. Thank you.</p>
  
  <pre><code>[Done] exited with code=null in 820.376 seconds
  </code></pre>