Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-131498: Cases generator: Parse down to C statement level.#131948

Merged
markshannon merged 14 commits into
python:mainpython/cpython:mainfrom
faster-cpython:code-gen-add-parserfaster-cpython/cpython:code-gen-add-parserCopy head branch name to clipboard
Apr 2, 2025
Merged

GH-131498: Cases generator: Parse down to C statement level.#131948
markshannon merged 14 commits into
python:mainpython/cpython:mainfrom
faster-cpython:code-gen-add-parserfaster-cpython/cpython:code-gen-add-parserCopy head branch name to clipboard

Conversation

@markshannon

@markshannon markshannon commented Mar 31, 2025

Copy link
Copy Markdown
Member

This PR enhances the cases generator parser to parse instructions and labels down to C statement level.

This:

  • Simplifies the rest of the code generator.
  • Enables us to treat #if conditionals like normal if statements ensuring that the free-threading and default builds have the same properties and are properly understood by the code generator.

Because we are now parsing the source, rather than simply tokenizing it, the output no longer contains the comments present in the original.

Comment thread Tools/cases_generator/generators_common.py
Comment thread Tools/cases_generator/parsing.py Outdated
raise NotImplementedError()


@dataclass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe to reduce memory footprint, use slots=True

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think it is worth it to save a few kbytes.

Comment thread Tools/cases_generator/parsing.py Outdated
Comment thread Tools/cases_generator/parsing.py Outdated
Comment thread Tools/cases_generator/parsing.py
Comment thread Tools/cases_generator/generators_common.py Outdated
@markshannon markshannon marked this pull request as ready for review April 2, 2025 13:57
@markshannon markshannon merged commit ad053d8 into python:main Apr 2, 2025
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.