[issue33682] Optimize the bytecode for float(0) ?
STINNER Victor
report at bugs.python.org
Tue May 29 08:50:46 EDT 2018
STINNER Victor <vstinner at redhat.com> added the comment:
float and int names can be replaced in the current namespace, so you cannot implement such optimization :-(
http://fatoptimizer.readthedocs.io/en/latest/optimizations.html#call-pure
http://fatoptimizer.readthedocs.io/en/latest/semantics.html#builtin-functions-replaced-in-the-middle-of-a-function
Example in the REPL:
>>> float=bool
>>> float(0)
False
>>> int=len
>>> int("hello world!")
12
I suggest to close this issue as NOTABUG. You need to implement guards at runtime to implement such optimizations without breaking the Python semantics. It is exactly what I implemented in my FAT Python project:
https://faster-cpython.readthedocs.io/fat_python.html
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33682>
_______________________________________
More information about the Python-bugs-list
mailing list