Serhiy Storchaka added the comment:
FYI this optimization is already implemented in 3.5+.
>>> def fo():
... if a:
... if b:
... if c:
... print()
...
>>> import dis
>>> dis.dis(fo)
2 0 LOAD_GLOBAL 0 (a)
2 POP_JUMP_IF_FALSE 18
3 4 LOAD_GLOBAL 1 (b)
6 POP_JUMP_IF_FALSE 18
4 8 LOAD_GLOBAL 2 (c)
10 POP_JUMP_IF_FALSE 18
5 12 LOAD_GLOBAL 3 (print)
14 CALL_FUNCTION 0
16 POP_TOP
>> 18 LOAD_CONST 0 (None)
20 RETURN_VALUE
----------
nosy: +serhiy.storchaka
resolution: -> out of date
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17430>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com