while (a=b()) ... (transmogrified to a range thread)

Tim Peters tim_one at email.msn.com
Wed May 19 01:41:43 EDT 1999


[Jeremy Hylton]
> ...
> Right.  I was timing an iteration over the range --
>     for i in xrange(N): pass
> vs.
>     for i in range(N): pass
> In this case, range nearly always wins -- even for N == 1000000.

Which is a highly platform-dependent result.  Last time Guido dissed xrange
he was timing it on a Sparc; but here in WinTelLand xrange can have a
significant speed advantage, presumably due to poorer cache performance
(although I've never tracked it down to the circuit, not particularly caring
why one way or the other <wink>).

Devious experiment:  try swapping the order of those two lines and see
whether range still wins.

if-it's-consistent-under-permutation-it-*might*-even-be-real-ly y'rs  - tim






More information about the Python-list mailing list