New submission from Stéphane Wirtel <steph...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue33682>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to