Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Merged
merged 4 commits into from
Aug 28, 2024

Conversation

wrongnull
Copy link
Contributor

@wrongnull wrongnull commented Aug 27, 2024

@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
@@ -3090,16 +3090,16 @@ def assert_ast(self, code, non_optimized_target, optimized_target):
f"{ast.dump(optimized_tree)}",
)

def create_binop(self, operand, left=ast.Constant(1), right=ast.Constant(1)):
Copy link
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
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
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
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

@JelleZijlstra JelleZijlstra merged commit be083ce into python:main Aug 28, 2024
39 checks passed
@miss-islington-app
Copy link

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 <[email protected]>
Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Aug 28, 2024

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 <[email protected]>
Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
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