title: Time taken by set vs list with for and if
body: <p>I have two collections and i need to find if the two collections have anything in common and if they do what are they.
  I can do it using lists and for and if or sets and finding the intersection.
  but I also need to minimize the time taken to run.</p>
  
  <p>Which of the two approaches is more time efficient?
  Note: Differences of the scale of a second is also important.</p>
  
  <p>EDIT:
  What i mean by collection is a collection of values. read from a csv for example. i may put them in a list or set for further operations.
  Example:
  a = ['D','C','B','A']
  b = ['A','B',E',Z','N','W']</p>
  
  <p>Now i can do it in the following ways?</p>
  
  <pre><code>common=[]
  for item in a:
      if item not in b:
          common.append(item)
  </code></pre>
  
  <p>using list comprehension</p>
  
  <pre><code>common=[item for item in a if item not in b]
  </code></pre>
  
  <p>using set</p>
  
  <pre><code>set(a) &amp; set(b)
  </code></pre>
  
  <p>I am unable to use just time command from linux since that is varying hugely from system to system</p>