[Python-Dev] On the possibility of "optimizing" range() calls in
for-loops
Guido van Rossum
guido@python.org
Thu, 19 Jun 2003 08:19:46 -0400
> > www.python.org/sf/738094 for i in range(N) optimization
> >
> > The jury is still out on whether it is an elegant, brilliant patch or
> > a horrendous hack.
Isn't this flawed in the case where it's called by a C function rather
than directly from the bytecode VM? If the C function was called in
the spot marked X below:
for ... in X(...): ...
(where X is the C function that calls range(), probably through some
PyObject_Call() variation), then the check in the patch would trigger
incorrectly.
--Guido van Rossum (home page: http://www.python.org/~guido/)