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

gh-102021 : Allow multiple input files for interpreter loop generator #102022

Merged
merged 4 commits into from
Mar 4, 2023

Conversation

jbower-fb
Copy link
Contributor

@jbower-fb jbower-fb commented Feb 18, 2023

I'm not sure a NEWS blurb is needed as the generator is entirely new in 3.12 anyway.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@arhadthedev
Copy link
Member

@gvanrossum @iritkatriel as authors of cases_generator.

@gvanrossum
Copy link
Member

I would like to wait reviewing until I am back from my break, around 2/27.

@gvanrossum gvanrossum self-requested a review February 28, 2023 22:55
@gvanrossum gvanrossum self-assigned this Feb 28, 2023
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! I have a few suggestions, feel free to push back!

Tools/cases_generator/generate_cases.py Outdated Show resolved Hide resolved
instrs: dict[str, Instruction] # Includes ops
supers: dict[str, parser.Super]
super_instrs: dict[str, SuperInstruction]
macros: dict[str, parser.Macro]
macro_instrs: dict[str, MacroInstruction]
families: dict[str, parser.Family]

def every_thing(self) -> Iterable[parser.InstDef | parser.Super | parser.Macro]:
return itertools.chain(
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a big fan of itertools.chain. Maybe make this a generator?

I also noticed this is causing the output to be emitted in a different order again. But I quite like having the generated instructions in the same order as they occur in the input. Could you restore that behavior? (I understand that it's a little tricky due to overrides. Ideally there would be a comment left in the output for instructions that are overridden by later ones.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I've changed things now so the output will retain the definition order and if there are overrides they'll look something like this:

...
        // TARGET(NOP) overridden by later definition
...
        // Override
        TARGET(NOP) {
            DISPATCH();

Tools/cases_generator/generate_cases.py Show resolved Hide resolved
Tools/cases_generator/generate_cases.py Outdated Show resolved Hide resolved
Tools/cases_generator/generate_cases.py Outdated Show resolved Hide resolved
@gvanrossum
Copy link
Member

gvanrossum commented Mar 3, 2023

(In the future please don't force push. It makes things more complicated for the reviewer, and we squash commits at the end anyway.)

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

LG!

I'll apply the small correction to the metadata header comment, wait for tests to pass again, and merge it. Thanks!

Python/opcode_metadata.h Outdated Show resolved Hide resolved
Tools/cases_generator/generate_cases.py Outdated Show resolved Hide resolved
@jbower-fb
Copy link
Contributor Author

Great, thank you.

@gvanrossum gvanrossum merged commit 8de59c1 into python:main Mar 4, 2023
carljm added a commit to carljm/cpython that referenced this pull request Mar 4, 2023
* main:
  pythongh-102021 : Allow multiple input files for interpreter loop generator (python#102022)
  Add import of `unittest.mock.Mock` in documentation (python#102346)
  pythongh-102383: [docs] Arguments of `PyObject_CopyData` are `PyObject *` (python#102390)
  pythongh-101754: Document that Windows converts keys in `os.environ` to uppercase (pythonGH-101840)
  pythongh-102324: Improve tests of `typing.override` (python#102325)
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 6, 2023
@jbower-fb jbower-fb deleted the multiple-cases branch May 1, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants