Serhiy Storchaka added the comment: Some examples.
if not a and b: x Unpatched: 1 0 LOAD_NAME 0 (a) 2 UNARY_NOT 4 POP_JUMP_IF_FALSE 14 6 LOAD_NAME 1 (b) 8 POP_JUMP_IF_FALSE 14 10 LOAD_NAME 2 (x) 12 POP_TOP >> 14 LOAD_CONST 0 (None) 16 RETURN_VALUE Patched: 1 0 LOAD_NAME 0 (a) 2 POP_JUMP_IF_TRUE 12 4 LOAD_NAME 1 (b) 6 POP_JUMP_IF_FALSE 12 8 LOAD_NAME 2 (x) 10 POP_TOP >> 12 LOAD_CONST 0 (None) 14 RETURN_VALUE if a <= b < c: x Unpatched: 1 0 LOAD_NAME 0 (a) 2 LOAD_NAME 1 (b) 4 DUP_TOP 6 ROT_THREE 8 COMPARE_OP 1 (<=) 10 JUMP_IF_FALSE_OR_POP 18 12 LOAD_NAME 2 (c) 14 COMPARE_OP 0 (<) 16 JUMP_FORWARD 4 (to 22) >> 18 ROT_TWO 20 POP_TOP >> 22 POP_JUMP_IF_FALSE 28 24 LOAD_NAME 3 (x) 26 POP_TOP >> 28 LOAD_CONST 0 (None) 30 RETURN_VALUE Patched: 1 0 LOAD_NAME 0 (a) 2 LOAD_NAME 1 (b) 4 DUP_TOP 6 ROT_THREE 8 COMPARE_OP 1 (<=) 10 POP_JUMP_IF_FALSE 20 12 LOAD_NAME 2 (c) 14 COMPARE_OP 0 (<) 16 POP_JUMP_IF_FALSE 28 18 JUMP_FORWARD 4 (to 24) >> 20 POP_TOP 22 JUMP_FORWARD 4 (to 28) >> 24 LOAD_NAME 3 (x) 26 POP_TOP >> 28 LOAD_CONST 0 (None) 30 RETURN_VALUE if not (a and b) and c: x Unpatched: 1 0 LOAD_NAME 0 (a) 2 JUMP_IF_FALSE_OR_POP 6 4 LOAD_NAME 1 (b) >> 6 UNARY_NOT 8 POP_JUMP_IF_FALSE 18 10 LOAD_NAME 2 (c) 12 POP_JUMP_IF_FALSE 18 14 LOAD_NAME 3 (x) 16 POP_TOP >> 18 LOAD_CONST 0 (None) 20 RETURN_VALUE Patched: 1 0 LOAD_NAME 0 (a) 2 POP_JUMP_IF_FALSE 8 4 LOAD_NAME 1 (b) 6 POP_JUMP_IF_TRUE 16 >> 8 LOAD_NAME 2 (c) 10 POP_JUMP_IF_FALSE 16 12 LOAD_NAME 3 (x) 14 POP_TOP >> 16 LOAD_CONST 0 (None) 18 RETURN_VALUE Note that the __bool__() method of every value is evaluated only once. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30501> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com