One Python 2.1 idea
rturpin at my-deja.com
rturpin at my-deja.com
Mon Dec 25 10:45:08 EST 2000
In article <mailman.977737448.26875.python-list at python.org>,
Peter Schneider-Kamp <peter at schneider-kamp.de> wrote:
> I see ome good reasons for enhancing the "for" statement:
>
> - loop counter iteration will give a speedup by avoiding
> construction of a list and looping over that list.
> - looping a certain amount of times is a frequent construct
Yes, this is a good performance optimization. BUT it
requires NO CHANGE in how loops are written. The WRONG
way to do this is to provide another construct in the
language, making it more complex, but giving it no
more expressive power. The RIGHT way to do this is
for the compiler to recognize the common construct:
for i in range(<exp1>: <exp2>):
The compiler then generates efficient byte code that
does precisely what you describe. It can generate a
minimal "ghost" of a list for the iteration, because
there is no way that future code can do anything else
with that list.
Russell
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list