Skip to content

gh-123344: Add missing ast optimizations for PEP 696#123377

Merged
JelleZijlstra merged 4 commits into
python:mainfrom
wrongnull:ast_opts_for_pep_696
Aug 28, 2024
Merged

gh-123344: Add missing ast optimizations for PEP 696#123377
JelleZijlstra merged 4 commits into
python:mainfrom
wrongnull:ast_opts_for_pep_696

Conversation

@wrongnull

@wrongnull wrongnull commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

@wrongnull
wrongnull requested a review from isidentical as a code owner August 27, 2024 06:52
@wrongnull
wrongnull marked this pull request as draft August 27, 2024 06:52
@Eclips4 Eclips4 changed the title gh-123344: Add missing ast optimizations for pep696 gh-123344: Add missing ast optimizations for PEP 696 Aug 27, 2024
@wrongnull
wrongnull marked this pull request as ready for review August 27, 2024 10:22
@Eclips4 Eclips4 added the needs backport to 3.13 bugs and security fixes label Aug 27, 2024
@Eclips4
Eclips4 requested a review from vstinner August 27, 2024 17:57
f"{ast.dump(optimized_tree)}",
)

def create_binop(self, operand, left=ast.Constant(1), right=ast.Constant(1)):

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.

Suggested change
def create_binop(self, operand, left=ast.Constant(1), right=ast.Constant(1)):
def create_binop(self, operand, left=None, right=None):

please, don't use complex objects as defaults

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.

This seems fine as is; it's more convenient to write many of the remaining tests this way.

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.

I am in a purist camp :) But, this is minor, I agree. Since these objects aren't ever mutated, this does not introduce any problems.

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.

Yeah, I also don't like mutable defaults. But this one looks not very complex and it doesn't seem to be mutated anytime soon :) We can rewrite it, but the diff would be much larger

Comment thread Misc/NEWS.d/next/Core and Builtins/2024-08-27-13-16-40.gh-issue-123344.56Or78.rst Outdated
…e-123344.56Or78.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@JelleZijlstra
JelleZijlstra merged commit be083ce into python:main Aug 28, 2024
@miss-islington-app

Copy link
Copy Markdown

Thanks @wrongnull for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 28, 2024
…123377)

(cherry picked from commit be083ce)

Co-authored-by: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-app

bedevere-app Bot commented Aug 28, 2024

Copy link
Copy Markdown

GH-123427 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 28, 2024
JelleZijlstra added a commit that referenced this pull request Aug 28, 2024
… (#123427)


(cherry picked from commit be083ce)

Co-authored-by: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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.

4 participants