Author eryksun
Recipients eryksun, opstad
Date 2018-07-24.14:47:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532443674.62.0.56676864532.issue34208@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2018-07-24 14:47:54eryksunsetrecipients: + eryksun, opstad
2018-07-24 14:47:54eryksunsetmessageid: <1532443674.62.0.56676864532.issue34208@psf.upfronthosting.co.za>
2018-07-24 14:47:54eryksunlinkissue34208 messages
2018-07-24 14:47:54eryksuncreate