On Fri, 3 Sep 2010 21:17:44 +0100, "BartC" <> declaimed
the following in gmane.comp.python.general:
> I'm not sure the Python developers were interested in getting fast loops.
>
> For-loops which iterate between two numbers are amongst the easiest things
> to make fast in a language. Yet originally you had to use:
>
> for i in range(N):
>
> which (if I understood correctly) actually created a list of N objects,
> populated it with the values 0, 1, 2...N-1 (presumably using a more sensible
> loop), then iterated between the values of the list!
>
In those languages in which a for loop cycles over a range of
integral values (or even floating point values) one often ends up with
code that then performs subscripting to access the real goal of the
loop...
The Python for loop is innately focused on giving one an object from
some iterable (list, tuple, dictionary, user-defined...) with which one
can directly process... Compare {pseudo-code}:
for item in world_objects:
item.update(simulation_time)
to
for i in range(len(world_objects)):
world_objects[i].update(simulation_time)
Those languages that have optimized numeric-only (integer-only in
some cases) for loops do not support the clean interface of the first
sample and force all access to look like the latter.
--
Wulfraed Dennis Lee Bieber AF6VN
HTTP://wlfraed.home.netcom.com/