[issue26722] Fold compare operators on constants (peephole)

STINNER Victor report at bugs.python.org
Sat Apr 9 09:17:01 EDT 2016


STINNER Victor added the comment:

Hi, it looks like the author of the peephole optimizer is Raymond Hettinger and he doesn't look to want to handle too many cases, he prefers to keep the code simple.

FYI I reimplemented recently the peephole optimizer in pure Python as part of the bytecode project:
https://bytecode.readthedocs.org/en/latest/peephole.html

I didn't write it to replace the C implementation, it was more a tool to discuss modifying bytecode (when discussing the PEP 511).

More generally, there is an ongoging discussion of rewriting the peephole optimizer to work on the AST rather than working on the Python code. The FAT Python implements that in pure Python:
https://faster-cpython.readthedocs.org/fat_python.html

FAT Python is more than a peephole optimizer, it's more a framework to implement more optimizations. Well, take a look.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26722>
_______________________________________


More information about the Python-bugs-list mailing list