Boris Borcic <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: >> Whereas when "3.0*1.0 is 3.0" is evaluated, *two* different float >> objects are put on the stack and compared (LOAD_CONST 3 / LOAD_CONST >> 1 / COMPARE_OP 8). Therefore the result is False. > > Looks good, but doesn't pass the sanity check ;) Consider > > >>> def f(): > return 3 is 3, 3*1 is 3 > > >>> import dis > >>> dis.dis(f) > 2 0 LOAD_CONST 1 (3) > 3 LOAD_CONST 1 (3) > 6 COMPARE_OP 8 (is) > 9 LOAD_CONST 3 (3) > 12 LOAD_CONST 1 (3) > 15 COMPARE_OP 8 (is) > 18 BUILD_TUPLE 2 > 21 RETURN_VALUE > >>> f() > (True, True) >
s/different/possibly different depending on implementation details/ Arnaud's point remains valid: in the first comparison you can see that the same object is used, in the second case all bets are off. -- http://mail.python.org/mailman/listinfo/python-list