title: Iterating Subset of Indices Efficiency
body: <p>I'm trying to iterate through a subset of elements in a list based on another list of indices. </p>
  
  <p>The shortest / most pythonic way seems like it would use list comprehension to the effect of:</p>
  
  <pre><code>    for elt in [lst[idx] for idx in idxs]:
          elt.do_stuff()
          elt.do_more_stuff()
  </code></pre>
  
  <p>But I can't shake the feeling that if I'm going to be looping this a lot, rebuilding the list comprehension every time might be expensive and I should spend the extra line to just write:</p>
  
  <pre><code>    for idx in indxs:
          elt = lst[idx]
          elt.do_stuff()
          elt.do_more_stuff()
  </code></pre>
  
  <p>Can someone who knows more about python and its relative efficiencies / inefficiencies way in on the actual computational cost difference between these approaches? I know, I know both ways could probably work fine, but once I started wondering about the difference it got me curious.</p>