[Python-Dev] On the possibility of "optimizing" range() calls in for-loops

Raymond Hettinger python@rcn.com
Sun, 15 Jun 2003 23:59:33 -0400


[Chad Netzer]
> The main issue, as I see it, is substituting some form of lazy range
> iterator, for the range() function, "behind the curtains" as it were.
> People could gain the benefits of xrange() (less memory consumption,
> probably faster looping), without having to promote the continued use
> of xrange().

The SF patch manager has a workable implementation of your idea:

    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.


Raymond Hettinger