title: Python next iterator in a loop
body: <p>I have a small routine like this:</p>
  
  <pre><code>to_use = [True] * n
  val = 0
  while (val is not None) :
     # various manipulations on val
     # so the val below is different from
     # val entering the loop
     to_use[val] = False
     val = next((i for i in range(n) if to_use[i]),None)
  </code></pre>
  
  <p>In my sample, <code>n</code> is of the order of a millon. Is the last like with the iterator the most efficient way to get the next "<code>val</code>"?. Or will it go through <code>to_use</code> from <code>0</code> each time in the loop? Note that once <code>to_use[i]=False</code>, its never reset to <code>True</code>.</p>