Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. #17754

Merged
merged 4 commits into from Jan 14, 2020

Conversation

@markshannon
Copy link
Contributor

markshannon commented Dec 30, 2019

Breaks up COMPARE_OP into four logically distinct opcodes:

  • COMPARE_OP for rich comparisons
  • IS_OP for 'is' and 'is not' tests
  • CONTAINS_OP for 'in' and 'is not' tests
  • JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.

This improves the clarity of the interpreter and should provide a modest speedup.

https://bugs.python.org/issue39156

@markshannon markshannon force-pushed the markshannon:breakup-compare-op branch 3 times, most recently from 3f4e3d4 to 2ee4c16 Dec 30, 2019
Copy link
Contributor

ZackerySpytz left a comment

I have some minor comments.

@@ -961,6 +975,13 @@ All of the following opcodes use their arguments.

.. versionadded:: 3.1

.. opcode:: JUMP_IF_NOT_EXC_MATCH (target)

Tests whether the second value on the stack is an exception matching TOS, and jumps if it is not.

This comment has been minimized.

Copy link
@ZackerySpytz

ZackerySpytz Jan 9, 2020

Contributor

This should be wrapped at 80 chars.

PyObject *left = POP();
if (PyTuple_Check(right)) {
Py_ssize_t i, length;
length = PyTuple_Size(right);

This comment has been minimized.

Copy link
@ZackerySpytz

ZackerySpytz Jan 9, 2020

Contributor

I think PyTuple_GET_SIZE() should be used here.

if (PyTuple_Check(right)) {
Py_ssize_t i, length;
length = PyTuple_Size(right);
for (i = 0; i < length; i += 1) {

This comment has been minimized.

Copy link
@ZackerySpytz

ZackerySpytz Jan 9, 2020

Contributor

i++

int res = PyErr_GivenExceptionMatches(left, right);
Py_DECREF(left);
Py_DECREF(right);
if (res > 0) {

This comment has been minimized.

Copy link
@ZackerySpytz

ZackerySpytz Jan 9, 2020

Contributor

IMO, this check for res > 0 should not be included.

This comment has been minimized.

Copy link
@markshannon

markshannon Jan 9, 2020

Author Contributor

Why?

markshannon added 2 commits Dec 29, 2019
   COMPARE_OP for rich comparisons
   IS_OP for 'is' and 'is not' tests
   CONTAINS_OP for 'in' and 'is not' tests
   JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
@markshannon markshannon force-pushed the markshannon:breakup-compare-op branch from 3e24674 to 8dbef33 Jan 10, 2020
@markshannon markshannon force-pushed the markshannon:breakup-compare-op branch from 8dbef33 to 1486559 Jan 10, 2020
@markshannon markshannon reopened this Jan 10, 2020
@markshannon markshannon requested a review from python/windows-team as a code owner Jan 13, 2020
@markshannon markshannon force-pushed the markshannon:breakup-compare-op branch from 8f56c51 to 449cb17 Jan 13, 2020
@markshannon markshannon force-pushed the markshannon:breakup-compare-op branch from 449cb17 to 5c9a327 Jan 13, 2020
@markshannon markshannon merged commit 9af0e47 into python:master Jan 14, 2020
9 checks passed
9 checks passed
Docs
Details
Windows (x86)
Details
Windows (x64)
Details
macOS
Details
Ubuntu
Details
Azure Pipelines PR #20200113.22 succeeded
Details
bedevere/issue-number Issue number 39156 found
Details
bedevere/news News entry found in Misc/NEWS.d
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@markshannon markshannon deleted the markshannon:breakup-compare-op branch Jan 14, 2020
petdance added a commit to petdance/cpython that referenced this pull request Jan 17, 2020
…ythonGH-17754)

Break up COMPARE_OP into four logically distinct opcodes:
* COMPARE_OP for rich comparisons
* IS_OP for 'is' and 'is not' tests
* CONTAINS_OP for 'in' and 'is not' tests
* JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
petdance added a commit to petdance/cpython that referenced this pull request Jan 17, 2020
…ythonGH-17754)

Break up COMPARE_OP into four logically distinct opcodes:
* COMPARE_OP for rich comparisons
* IS_OP for 'is' and 'is not' tests
* CONTAINS_OP for 'in' and 'is not' tests
* JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
petdance added a commit to petdance/cpython that referenced this pull request Jan 17, 2020
…ythonGH-17754)

Break up COMPARE_OP into four logically distinct opcodes:
* COMPARE_OP for rich comparisons
* IS_OP for 'is' and 'is not' tests
* CONTAINS_OP for 'in' and 'is not' tests
* JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.