How come unpacking is faster than accessing by index?
<p>I'm referring to this question, and especially the comments to the first answer from @David Robinson and @mgilson:
<a href="http://stackoverflow.com/q/12218112/341971">Sum the second value of each tuple in a list</a></p>

<p>The original question was to sum the second value of each tuble:</p>

<pre><code>structure = [('a', 1), ('b', 3), ('c', 2)]
</code></pre>

<p>First Answer:</p>

<pre><code>sum(n for _, n in structure)
</code></pre>

<p>Second Answer:</p>

<pre><code>sum(x[1] for x in structure)
</code></pre>

<p>According to discussion, the first answer is 50% faster.</p>

<p>Once I figured out what the first answer does (coming from Perl, I Googled for the special _ variable means in python), I got wondering how come what appears as a pure subset task (getting only the second element of each tuple vs. getting and binding into variables both elements) is actually slower? Is it a missing opportunity to optimize index access in Python? Am I missing something the second answer does which takes time?</p>
