Itertools vs Nested Loops Performance
<p>I have to generate all the 2-pair combinations of items in a list. Now, I know of two ways to accomplish this: nested for-loops, and python's built-in <em>itertools</em>:</p>

<pre><code>from itertools import combinations

foo = [1, 2, 3, 4]

for i in xrange(len(foo)):
    for j in xrange(i + 1, len(foo)):
        print foo[i], foo[j]

for c in  combinations(foo, 2):
    print c
</code></pre>

<p>My question is: are there any significant advantages to using one over the other?</p>