[issue39156] Break up COMPARE_OP into logically distinct operations.

Mark Shannon report at bugs.python.org
Mon Dec 30 05:42:20 EST 2019


Mark Shannon <mark at hotpy.org> added the comment:

Moving work from the interpreter to the compiler is always a good idea.

Performance: The compiler is run once per code unit, the interpreter thousands or millions of times.

The compiler is easier to test. Just match the expected bytecode with the actual bytecode. 
The output can be sanity checked by visual inspection.


Although I expect a performance boost, I think this is a worthwhile improvement whether or not it helps 
performance as it makes the instructions better focused.


Pablo, currently there are 117 opcodes, increasing that to 120 is not a problem.
Also there is no reason why we are limited to 256 opcodes in the long term.
Plus, I'm 4 opcodes in credit, thanks to https://bugs.python.org/issue33387 :)

Raymond, regarding the performance of COMPARE_OP, it is not just branch prediction that matters. With this change, the number of (hardware) instructions executed is always reduced, even if branch prediction is no better.

Serhiy, the benefit of having a special opcode for exception matching is not really to speed up exception matching, but to avoid slowing down other tests.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39156>
_______________________________________


More information about the Python-bugs-list mailing list