[issue18208] Wrong bytecode generated for 'in' operation
New submission from Phil Connell: The following two expressions should have the same value: Python 3.4.0a0 (default:fae92309c3be, Jun 14 2013, 09:29:54) [GCC 4.8.0] on linux Type help, copyright, credits or license for more information. 1 in [2] == False False (1 in [2]) == False True It looks like this is a compiler issue - there shouldn't be a jump if the 'in' expression is false: dis.dis(1 in [2] == False) 1 0 LOAD_CONST 0 (1) 3 LOAD_CONST 1 (2) 6 BUILD_LIST 1 9 DUP_TOP 10 ROT_THREE 11 COMPARE_OP 6 (in) 14 JUMP_IF_FALSE_OR_POP24 17 LOAD_CONST 2 (False) 20 COMPARE_OP 2 (==) 23 RETURN_VALUE 24 ROT_TWO 25 POP_TOP 26 RETURN_VALUE -- components: Interpreter Core messages: 191108 nosy: benjamin.peterson, brett.cannon, georg.brandl, isoschiz, ncoghlan, pconnell priority: normal severity: normal status: open title: Wrong bytecode generated for 'in' operation ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18208] Wrong bytecode generated for 'in' operation
Amaury Forgeot d'Arc added the comment: This is one case of chained comparisons: http://docs.python.org/3/reference/expressions.html#not-in x = y = z is equivalent to (x = y) and (y = z) x in y == z is equivalent to (x in y) and (y == z) There is a jump if the 'in' expression is false, because 'and' should short-circuit the second comparison. -- nosy: +amaury.forgeotdarc resolution: - invalid status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18208] Wrong bytecode generated for 'in' operation
Phil Connell added the comment: Thanks Amaury. That's quite surprising, but I wouldn't advocate changing such long standing behaviour. I'm closing the issue. -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18208 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com