Eryk Sun <eryk...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue34208>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to