Paul Pogonyshev <[EMAIL PROTECTED]> added the comment:

Also, this is the reason for while() in the patch.  Consider this function:

def bar(a, b, c):
    if a:
        if b:
            if c:
                return 'true'

Before the patch:
 11           0 LOAD_FAST                0 (a)
              3 JUMP_IF_FALSE           27 (to 33)
              6 POP_TOP

 12           7 LOAD_FAST                1 (b)
             10 JUMP_IF_FALSE           16 (to 29)
             13 POP_TOP

 13          14 LOAD_FAST                2 (c)
             17 JUMP_IF_FALSE            5 (to 25)
             20 POP_TOP

 14          21 LOAD_CONST               1 ('true')
             24 RETURN_VALUE
        >>   25 POP_TOP
             26 JUMP_ABSOLUTE           34
        >>   29 POP_TOP
             30 JUMP_FORWARD             1 (to 34)
        >>   33 POP_TOP
        >>   34 LOAD_CONST               0 (None)
             37 RETURN_VALUE

After:
 11           0 LOAD_FAST                0 (a)
              3 JUMP_IF_FALSE           27 (to 33)
              6 POP_TOP

 12           7 LOAD_FAST                1 (b)
             10 JUMP_IF_FALSE           20 (to 33)
             13 POP_TOP

 13          14 LOAD_FAST                2 (c)
             17 JUMP_IF_FALSE           13 (to 33)
             20 POP_TOP

 14          21 LOAD_CONST               1 ('true')
             24 RETURN_VALUE
             25 POP_TOP
             26 JUMP_ABSOLUTE           34
             29 POP_TOP
             30 JUMP_FORWARD             1 (to 34)
        >>   33 POP_TOP
        >>   34 LOAD_CONST               0 (None)
             37 RETURN_VALUE

Without the while(), target for jump at offset 17 wouldn't be optimized,
because "jump to unconditional jump" optimization hasn't been done yet:
it is farther in the code.

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2260>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to