title: python generator is too slow to use it. why should I use it? and when?
body: <p>Recently I got question about which one is the most fastest thing among <code>iterator</code>, <code>list comprehension</code>, <code>iter(list comprehension)</code> and <code>generator</code>. 
  and then make simple code as below. </p>
  
  <pre><code>n = 1000000
  iter_a = iter(range(n))
  list_comp_a = [i for i in range(n)]
  iter_list_comp_a = iter([i for i in range(n)])
  gene_a = (i for i in range(n))
  
  import time
  import numpy as np
  
  for xs in [iter_a, list_comp_a, iter_list_comp_a, gene_a]:
      start = time.time()
      np.sum(xs)
      end = time.time()
      print((end-start)*100)
  </code></pre>
  
  <p>the result is below. </p>
  
  <pre><code>0.04439353942871094 # iterator
  9.257078170776367 # list_comprehension
  0.006318092346191406 # iterator of list_comprehension
  7.491207122802734 # generator 
  </code></pre>
  
  <p>generator is so slower than other thing. 
  and I don't know when it is useful? </p>