title: Python list intersection efficiency: generator or filter()?
body: <p>I would like to intersect two lists in Python (2.7). I need the result to be iterable:</p>
  
  <pre><code>list1 = [1,2,3,4]
  list2 = [3,4,5,6]
  result = (3,4) # any kind of iterable
  </code></pre>
  
  <p>Providing a <em>full iteration</em> will be performed first thing after the intersection, which of the following is more efficient?</p>
  
  <p>Using a generator:</p>
  
  <pre><code>result = (x for x in list1 if x in list2)
  </code></pre>
  
  <p>Using filter():</p>
  
  <pre><code>result = filter(lambda x: x in list2, list1)
  </code></pre>
  
  <p>Other suggestions?</p>
  
  <p>Thanks in advance,<br>
  Amnon</p>