¡@

Home 

python Programming Glossary: setup_loop

Why does Python code run faster in a function?

http://stackoverflow.com/questions/11241523/why-does-python-code-run-faster-in-a-function

this question Inside a function the bytecode is 2 0 SETUP_LOOP 20 to 23 3 LOAD_GLOBAL 0 xrange 6 LOAD_CONST 3 100000000 .. 0 None 26 RETURN_VALUE At top level the bytecode is 1 0 SETUP_LOOP 20 to 23 3 LOAD_NAME 0 xrange 6 LOAD_CONST 3 100000000 9..

Python: generator expression vs. yield

http://stackoverflow.com/questions/1995418/python-generator-expression-vs-yield

for j in xrange y ... yield i j ... dis.dis Generator 2 0 SETUP_LOOP 54 to 57 3 LOAD_GLOBAL 0 xrange 6 LOAD_FAST 0 x 9 CALL_FUNCTION.. 1 12 GET_ITER 13 FOR_ITER 40 to 56 16 STORE_FAST 2 i 3 19 SETUP_LOOP 31 to 53 22 LOAD_GLOBAL 0 xrange 25 LOAD_FAST 1 y 28 CALL_FUNCTION.. y ... dis.dis Generator_expr.func_code.co_consts 1 2 0 SETUP_LOOP 47 to 50 3 LOAD_FAST 0 .0 6 FOR_ITER 40 to 49 9 STORE_FAST..

while (1) Vs. for while(True) — Why is there a difference?

http://stackoverflow.com/questions/3815359/while-1-vs-for-whiletrue-why-is-there-a-difference

while_true produces the following results while 1 4 0 SETUP_LOOP 3 to 6 5 3 JUMP_ABSOLUTE 3 6 LOAD_CONST 0 None 9 RETURN_VALUE.. 3 6 LOAD_CONST 0 None 9 RETURN_VALUE while True 8 0 SETUP_LOOP 12 to 15 3 LOAD_GLOBAL 0 True 6 JUMP_IF_FALSE 4 to 13 9 POP_TOP.. the statements using identical operations while 1 4 0 SETUP_LOOP 3 to 6 5 3 JUMP_ABSOLUTE 3 6 LOAD_CONST 0 None 9 RETURN_VALUE..

Why is looping over range() in Python faster than using a while loop?

http://stackoverflow.com/questions/869229/why-is-looping-over-range-in-python-faster-than-using-a-while-loop

use while loop 1 0 LOAD_CONST 0 0 3 STORE_NAME 0 i 2 6 SETUP_LOOP 28 to 37 9 LOAD_NAME 0 i # 12 LOAD_CONST 1 100000000 # 15 COMPARE_OP.. POP_TOP 36 POP_BLOCK The loop body has 10 op use range 1 0 SETUP_LOOP 23 to 26 3 LOAD_NAME 0 range 6 LOAD_CONST 0 0 9 LOAD_CONST 1..