Why use a set for list comparisons?
<p>I just read another users question while looking for a way to compute the differences in two lists.</p>

<p><a href="http://stackoverflow.com/questions/6486450/python-compute-list-difference">Python, compute list difference</a></p>

<p>My question is why would I do</p>

<pre><code>def diff(a,b):
    b = set(b)
    return [aa for aa in a if aa not in b]
</code></pre>

<p>rather than doing</p>

<pre><code>def diff(a,b):
    tmp = []
    for i in a:
        if(i not in b):
            tmp.append(i)
return tmp
</code></pre>

<p>edit: just noticed the second diff function actually returned the similarities.  It should be correct now.</p>
