On 05/10/2013 05:19 PM, Jim Mooney wrote:
If I'm using a variable-dependent range in a for loop, is Python smart
enough to figure the variable once so I don't have to hoist it up?
That is for c in range(0,x+2), is x+2 figured once or every time
through the loop? I'm assuming it's once but I like to verify.
It's only done once.
I'll figure this myself once I get an editor I like with a profiler,
but I'm still trying editors and don't want to spend all my time on
them. So far I'm in between too simple, overkill, or buggy. And I
don't want anything that uses Java. I'm allergic to Java ;')
You don't need to use a profiler, or an IDE to answer a question like
this. A very useful thing is the dis module:
http://pymotw.com/2/dis/index.html
http://docs.python.org/library/dis.html#dis.disassemble
It shows you the output of the Python compiler. It doesn't take long to
learn to read the code it displays.
--
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor