Is using range() in for loops really Pythonic?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed May 14 02:37:55 EDT 2008
On Tue, 13 May 2008 10:20:41 -0700, John Nagle wrote:
> Matt Nordhoff wrote:
>
>> Well, you should use "xrange(10)" instead of "range(10)".
>
> CPython really is naive. That sort of thing should be a
> compile-time optimization.
It's not naive, it can't know at compile time what object is bound to the
name `xrange` at runtime.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list