[issue27127] Never have GET_ITER not followed by FOR_ITER

Raymond Hettinger report at bugs.python.org
Tue Jun 7 14:48:08 EDT 2016


Raymond Hettinger added the comment:

I don't think this should go forward.  The current FOR_ITER and JUMP_ABSOLUTE combination is very efficient and shouldn't be changed lightly.  It is the inside of the loop that matters -- the GET_ITER step is outside of the loop and isn't expensive.

Also, I really like that GET_ITER and FOR_ITER correspond exactly to our high level understanding of how for-loops operate:

   for x in s:
       f(x)

corresponds to:

   it = iter(s)
   while True:
       try:
           x = next(it)
       except StopIteration:
           break
       f(x)

I really don't think this should be pursued further.  It messes with my understanding of for-loops, it combines features that should remain decoupled, it focuses its efforts on the exterior of the loop, and it alters code that is very mature (having been examined and tweaked by hundreds of your predecessors).

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27127>
_______________________________________


More information about the Python-bugs-list mailing list