Skip to content

Avoid extra parentheses in yield expressions#7444

Merged
charliermarsh merged 1 commit intomainfrom
charlie/yield
Sep 16, 2023
Merged

Avoid extra parentheses in yield expressions#7444
charliermarsh merged 1 commit intomainfrom
charlie/yield

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Sep 16, 2023

Summary

This is equivalent to #7424, but for yield and yield from expressions. Specifically, we want to avoid adding unnecessary extra parentheses for yield expr when expr itself does not require parentheses.

Test Plan

cargo test

No change in any of the similarity metrics.

Before:

project similarity index total files changed files
cpython 0.76083 1789 1632
django 0.99982 2760 37
transformers 0.99957 2587 399
twine 1.00000 33 0
typeshed 0.99983 3496 18
warehouse 0.99929 648 16
zulip 0.99962 1437 22

After:

project similarity index total files changed files
cpython 0.76083 1789 1632
django 0.99982 2760 37
transformers 0.99957 2587 399
twine 1.00000 33 0
typeshed 0.99983 3496 18
warehouse 0.99929 648 16
zulip 0.99962 1437 22

@charliermarsh charliermarsh added the formatter Related to the formatter label Sep 16, 2023
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 16, 2023

CodSpeed Performance Report

Merging #7444 will improve performances by 4.76%

Comparing charlie/yield (ed6d3cb) with main (aae02cf)

Summary

⚡ 1 improvements
✅ 24 untouched benchmarks

Benchmarks breakdown

Benchmark main charlie/yield Change
formatter[large/dataset.py] 61.7 ms 58.9 ms +4.76%

@charliermarsh charliermarsh merged commit 422ff82 into main Sep 16, 2023
@charliermarsh charliermarsh deleted the charlie/yield branch September 16, 2023 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

formatter Related to the formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants