Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
[mypyc] feat: optimize f-string building from Final values#19611
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
35 commits Select commitHold shift + click to select a range
12e0a9d WIP [mypyc] optimize f-string building
BobTheBuidler5b44af1 Update specialize.py
BobTheBuidlerfc40c81 [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]61970f5 Update specialize.py
BobTheBuidlerc5ebd11 Update specialize.py
BobTheBuidler8a68800 Update specialize.py
BobTheBuidler996d852 Update specialize.py
BobTheBuidler3fe0a63 Update specialize.py
BobTheBuidlerc817b67 Update specialize.py
BobTheBuidler8636006 Update specialize.py
BobTheBuidler5cee243 Update specialize.py
BobTheBuidler8b50424 Update specialize.py
BobTheBuidler712b10a Update irbuild-str.test
BobTheBuidlerad58850 [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]a69ea3f Update format_str_tokenizer.py
BobTheBuidler5351050 Update format_str_tokenizer.py
BobTheBuidler5b32541 Update irbuild-str.test
BobTheBuidler0a03849 Update irbuild-str.test
BobTheBuidlera68c9f8 [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]0216858 Update specialize.py
BobTheBuidler6047b0f Update irbuild-str.test
BobTheBuidler7b3ca5b [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]ceb0e03 Update irbuild-str.test
BobTheBuidlerba03d50 Update irbuild-str.test
BobTheBuidlerfc973df Update irbuild-str.test
BobTheBuidler029b657 Update irbuild-str.test
BobTheBuidler8064845 fix ir whitespace
BobTheBuidler55c4a8d [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]e71e215 Merge branch 'master' into patch-3
BobTheBuidler417fa73 Update specialize.py
BobTheBuidleraed4c1d add more tests
BobTheBuidler1de5018 [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]212bee8 Update specialize.py
BobTheBuidler80a97a9 [pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]60c8af0 Merge branch 'master' into patch-3
BobTheBuidlerFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Update specialize.py
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit0216858266f7464bc29682dd28bb6e51ae5d212c
There are no files selected for viewing
18 changes: 5 additions & 13 deletionsmypyc/irbuild/specialize.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -712,16 +712,8 @@ def translate_fstring(builder: IRBuilder, expr: CallExpr, callee: RefExpr) -> Va | ||
| exprs.append(item.args[0]) | ||
| for i in range(len(exprs) - 1): | ||
| def get_literal_str(expr: Expression) -> str | None: | ||
| # NOTE: not sure where I should put this helper, this file? somewhere else? | ||
BobTheBuidler marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| if isinstance(expr, StrExpr): | ||
| return expr.value | ||
| elif ( | ||
| @@ -733,11 +725,11 @@ def get_literal_str(expr: Expression) -> str | None: | ||
| return None | ||
| while ( | ||
| len(exprs) >= i + 2 | ||
| and (first := get_literal_str(exprs[i])) is not None | ||
| and (second := get_literal_str(exprs[i + 1])) is not None | ||
| ): | ||
| exprs = [*exprs[:i], StrExpr(first + second), *exprs[i + 2 :]] | ||
| format_ops = [*format_ops[:i], FormatOp.STR, *format_ops[i + 2 :]] | ||
| substitutions = convert_format_expr_to_str(builder, format_ops, exprs, expr.line) | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.