title: What is best practice to use generators for counting purposes
body: <p>Let's say I have a list like:</p>
  
  <pre><code>my_list = range(10)
  </code></pre>
  
  <p>And I want to count how many even numbers there are in the list. Note that I am not interested with the values, I just want the count of them. So I can:</p>
  
  <pre><code>len( [0 for i in my_list if i % 2 == 0] ) # Method 1
  len( [i for i in my_list if i % 2 == 0] ) # Method 2
  len( [_ for i in my_list if i % 2 == 0] ) # Method 3
  </code></pre>
  
  <p>Is any of the above methods better than others from the speed or memory perspectives?</p>
  
  <p>Actually I don't even need to construct the list, but I don't want to:</p>
  
  <pre><code>counter = 0
  for item in my_list:
     if item % 2 == 0:
        counter += 1
  </code></pre>
  
  <p>So, which one is a good way of counting with generators?</p>
  
  <p>PS: The list in my case has more memory-heavy items, that is why I want to optimize if possible.</p>