
def f(): while True:
There is a piece of low hanging fruit in "while True" constructs. If the code generator can recognize it, then three op-codes can be shaved off of every pass (LOAD_GLOBAL, JUMP_IF_FALSE, and POP_TOP). Raymond Hettinger --------------------------------------------------------- print "hello"
dis.dis(f) 2 0 SETUP_LOOP 17 (to 20) >> 3 LOAD_GLOBAL 0 (True) 6 JUMP_IF_FALSE 9 (to 18) 9 POP_TOP
3 10 LOAD_CONST 1 ('hello') 13 PRINT_ITEM 14 PRINT_NEWLINE 15 JUMP_ABSOLUTE 3 -------------------------------------------------------- It would be great if lines 3, 6, and 9 were not generated or if line 15 was JUMP_ABSOLUTE 10.