◐ Shell
clean mode source ↗

Message 128810 - Python tracker

I think r82043 may also explain why 3.1.3 can fold the expression 2 * -3 into -6 while 3.2rc3 cannot.

# test.py
from dis import dis

def y(): 2 * -3

print("dis y:")
dis(y)



C:\tmp>c:\Python32\python.exe --version
Python 3.2rc3

C:\tmp>c:\Python32\python.exe test.py
dis y:
  3           0 LOAD_CONST               1 (2)
              3 LOAD_CONST               3 (-3)
              6 BINARY_MULTIPLY
              7 POP_TOP
              8 LOAD_CONST               0 (None)
             11 RETURN_VALUE

C:\tmp>c:\Python31\python.exe --version
Python 3.1.3

C:\tmp>c:\Python31\python.exe test.py
dis y:
  3           0 LOAD_CONST               3 (-6)
              3 POP_TOP
              4 LOAD_CONST               0 (None)
              7 RETURN_VALUE