This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Mark.Shannon
Recipients Mark.Shannon
Date 2019-12-29.19:44:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577648682.52.0.347690468964.issue39156@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-12-29 19:44:42Mark.Shannonsetrecipients: + Mark.Shannon
2019-12-29 19:44:42Mark.Shannonsetmessageid: <1577648682.52.0.347690468964.issue39156@roundup.psfhosted.org>
2019-12-29 19:44:42Mark.Shannonlinkissue39156 messages
2019-12-29 19:44:42Mark.Shannoncreate