STINNER Victor <vstin...@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 <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