Author vstinner
Recipients matrixise, vstinner
Date 2018-05-29.12:50:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527598246.3.0.682650639539.issue33682@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-05-29 12:50:46vstinnersetrecipients: + vstinner, matrixise
2018-05-29 12:50:46vstinnersetmessageid: <1527598246.3.0.682650639539.issue33682@psf.upfronthosting.co.za>
2018-05-29 12:50:46vstinnerlinkissue33682 messages
2018-05-29 12:50:46vstinnercreate