[issue34208] Change in 3.7 expression evaluation?
Eryk Sun
report at bugs.python.org
Tue Jul 24 10:47:54 EDT 2018
Eryk Sun <eryksun at gmail.com> added the comment:
Please refrain from using the issue tracker to satisfy your curiosity. This is a question about compiler optimizations that should be asked on python-list, or maybe python-dev.
You can use the dis module to get a superficial answer in terms of the constants in the code object.
3.6:
>>> dis.dis('(100 * 20) is 2000')
1 0 LOAD_CONST 3 (2000)
2 LOAD_CONST 2 (2000)
4 COMPARE_OP 8 (is)
6 RETURN_VALUE
3.7:
>>> dis.dis('(100 * 20) is 2000')
1 0 LOAD_CONST 0 (2000)
2 LOAD_CONST 0 (2000)
4 COMPARE_OP 8 (is)
6 RETURN_VALUE
The argument of the LOAD_CONST opcode is the index of the constant in the code object's co_consts tuple. In 3.6 you can see it's separate int objects, but in 3.7 the operation uses the same int object (index 0).
----------
nosy: +eryksun
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34208>
_______________________________________
More information about the Python-bugs-list
mailing list