New submission from Mark Shannon <m...@hotpy.org>:
Currently the COMPARE_OP instruction performs one of four different tasks. We should break it up into four different instructions, that each performs only one of those tasks. The four tasks are: Rich comparison (>, <, ==, !=, >=, <=) Identity comparison (is, is not) Contains test (in, not in) Exception matching The current implementation involves an unnecessary extra dispatch to determine which task to perform. Comparisons are common operations, so this extra call and unpredictable branch has a cost. In addition, testing for exception matching is always followed by a branch, so the test and branch can be combined. I propose adding three new instructions and changing the meaning of `COMPARE_OP`. COMPARE_OP should only perform rich comparisons, and should call `PyObject_RichCompare` directly. IS_OP performs identity tests, performs no calls and cannot fail. CONTAINS_OP tests for 'in and 'not in' and should call `PySequence_Contains` directly. JUMP_IF_NOT_EXC_MATCH Tests whether the exception matches and jumps if it does not. ---------- components: Interpreter Core messages: 359002 nosy: Mark.Shannon priority: normal severity: normal status: open title: Break up COMPARE_OP into logically distinct operations. type: performance versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39156> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com