[New-bugs-announce] [issue33682] Optimize the bytecode for float(0) ?

Stéphane Wirtel report at bugs.python.org
Tue May 29 08:47:12 EDT 2018


New submission from Stéphane Wirtel <stephane at wirtel.be>:

Hi,

Maybe already discussed with Victor but I think there is no optimization when we have this simple case for float(X) and int(X)

Example:

>>> import dis
>>> dis.dis("x = float(0)")
  1           0 LOAD_NAME                0 (float)
              2 LOAD_CONST               0 (0)
              4 CALL_FUNCTION            1
              6 STORE_NAME               1 (x)
              8 LOAD_CONST               1 (None)
             10 RETURN_VALUE
>>> dis.dis("x = 1 + 1")
  1           0 LOAD_CONST               0 (2)
              2 STORE_NAME               0 (x)
              4 LOAD_CONST               1 (None)
              6 RETURN_VALUE
>>> dis.dis("x = int(0)")
  1           0 LOAD_NAME                0 (int)
              2 LOAD_CONST               0 (0)
              4 CALL_FUNCTION            1
              6 STORE_NAME               1 (x)
              8 LOAD_CONST               1 (None)
             10 RETURN_VALUE
>>> 


There is an optim for x = 1 + 1

----------
messages: 318016
nosy: matrixise, vstinner
priority: normal
severity: normal
status: open
title: Optimize the bytecode for float(0) ?
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33682>
_______________________________________


More information about the New-bugs-announce mailing list