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-44511: Improve the bytecode for class and mapping patterns #26922

Merged
merged 14 commits into from Oct 27, 2021

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jun 27, 2021

@brandtbucher
Copy link
Member Author

brandtbucher commented Jun 27, 2021

asyncio failure on Windows (test_sendfile_close_peer_in_the_middle_of_receiving) looks unrelated.

@brandtbucher brandtbucher changed the title bpo-44511: Improve the bytecode for mapping patterns bpo-44511: Improve the bytecode for class and mapping patterns Jul 23, 2021
Copy link
Member

@markshannon markshannon left a comment

Looks like a nice improvement. A couple of minor comments

Lib/opcode.py Outdated
@@ -165,7 +165,7 @@ def jabs_op(name, op):
def_op('IS_OP', 117)
def_op('CONTAINS_OP', 118)
def_op('RERAISE', 119)

def_op('PUSH_PEEK', 120)
Copy link
Member

@markshannon markshannon Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All instructions push their result. Could you rename this to PEEK, or COPY.
I'd prefer COPY.

Copy link
Member Author

@brandtbucher brandtbucher Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wanted to just go with PEEK, but that conflicted with the PEEK macro in ceval.c.

I like COPY much better.

Python/ceval.c Outdated
@@ -4367,6 +4339,13 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
DISPATCH();
}

case TARGET(PUSH_PEEK): {
PyObject *peek = PEEK(oparg + 1);
Copy link
Member

@markshannon markshannon Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer PEEK(oparg).
I realize that would make oparg == 0 invalid, but counting from one is the convention when determining stack positions.

with a :class:`dict` formed from the items of TOS1, but without any of the
keys in TOS.

.. versionadded:: 3.10
Copy link
Member

@vstinner vstinner Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to document bytecode changes in What's New in Python 3.11? There is a bytecode section:
https://docs.python.org/dev/whatsnew/3.11.html#cpython-bytecode-changes

@brandtbucher
Copy link
Member Author

brandtbucher commented Oct 11, 2021

Thanks for your reviews! I'll resolve the current conflicts.

@markshannon
Copy link
Member

markshannon commented Oct 27, 2021

Looks good.

@markshannon markshannon merged commit 82a662e into python:main Oct 27, 2021
12 checks passed
@brandtbucher brandtbucher deleted the patma-refactor-mapping-patterns branch Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants