How much does Python optimize?

Blackbird fake at nospam.no
Fri Mar 3 04:26:04 EST 2006


Hello!

I think

for i in range(10):
    <some code that depends on i>


is more readable than a while loop with explicit incrementation of i.
However, range(10) in the command interpreter obviously returns a list.  Is
this list optimized away in the code above, or is it actually constructed
internally? (With, say, CPython in one of the recent versions.)





More information about the Python-list mailing list