Speed-up for loops

Aahz aahz at pythoncraft.com
Tue Sep 7 16:46:16 CEST 2010


In article <o4oho.85508$zA5.26124 at newsfe16.ams2>,
BartC <bartc at freeuk.com> wrote:
>"Steven D'Aprano" <steve-REMOVE-THIS at cybersource.com.au> wrote in message
>news:4c85adfe$0$11115$c3e8da3 at news.astraweb.com...
>> 
>> xrange = range
>>
>> There, that wasn't hard, was it?
>
>I think I just learned more about Python than from months of reading this
>group.
>
>So 'range' is just a class like any other. And that a class is something you
>can blithely copy from one variable to another. And whenever you see 'range'
>anywhere, you can't always be certain that someone hasn't done:
>
>range = 42
>
>at some point. That explains a lot about the difficulties of implementing
>Python efficiently. (And the xrange=range trick works well thanks.)

Actually, range() is a function.  But the same point applies, squared --
you really can never know what kind of object is hiding behind a name in
the general case.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"...if I were on life-support, I'd rather have it run by a Gameboy than a
Windows box."  --Cliff Wells



More information about the Python-list mailing list