dreampuf
2014-11-13 07:09:52 +08:00
区别大了
In [115]: dis.disassemble(compile("total & 0x01", "__file__", "single"))
1 0 LOAD_NAME 0 (total)
3 LOAD_CONST 0 (1)
6 BINARY_AND
7 PRINT_EXPR
8 LOAD_CONST 1 (None)
11 RETURN_VALUE
In [116]: dis.disassemble(compile("total == 1", "__file__", "single"))
1 0 LOAD_NAME 0 (total)
3 LOAD_CONST 0 (1)
6 COMPARE_OP 2 (==)
9 PRINT_EXPR
10 LOAD_CONST 1 (None)
13 RETURN_VALUE
In [117]: dis.disassemble(compile("total and 1", "__file__", "single"))
1 0 LOAD_NAME 0 (total)
3 JUMP_IF_FALSE_OR_POP 9
6 LOAD_CONST 0 (1)
>> 9 PRINT_EXPR
10 LOAD_CONST 1 (None)
13 RETURN_VALUE