[red-knot] Refactor: no mutability in call APIs#17788
Merged
Conversation
Contributor
|
450a150 to
7ddc065
Compare
AlexWaygood
approved these changes
May 2, 2025
Member
AlexWaygood
left a comment
There was a problem hiding this comment.
Nice, this seems cleaner for sure. Definitely worth it if perf is neutral/slightly better.
Member
|
Could also be worth running the |
Contributor
Author
|
Inconclusive (no statistically significant improvement/regression)
|
dcreager
reviewed
May 2, 2025
| F: FnOnce(&mut Self) -> R, | ||
| F: FnOnce(&Self) -> R, | ||
| { | ||
| let mut call_arguments = self.clone(); |
Member
There was a problem hiding this comment.
We don't need to clone when there's no bound_self. Opened #17793 for that, and to combine the clone/push_front into a single collect call, which should avoid a double-copy when there is a bound_self. (Or really, a copy + immediate move)
dcreager
added a commit
that referenced
this pull request
May 2, 2025
* main: [red-knot] Refactor: no mutability in call APIs (#17788) [red-knot] Fix panic for `tuple[x[y]]` string annotation (#17787) [red-knot] Implicit instance attributes in generic methods (#17769) doc: Add link to `check-typed-exception` from `S110` and `S112` (#17786) Fix module name in ASYNC110, 115, and 116 fixes (#17774) [red-knot] More informative hover-types for assignments (#17762) [syntax-errors] Use consistent message for bad starred expression usage. (#17772) red_knot_server: add auto-completion MVP Allow passing a virtual environment to `ruff analyze graph` (#17743) Bump 0.11.8 (#17766) [`flake8-use-pathlib`] Fix `PTH104`false positive when `rename` is passed a file descriptor (#17712)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Remove mutability in parameter types for a few functions such as
with_selfandtry_call. I tried theRc-approach with cheap cloning suggest here first, but it turns out we need a whole stack of prepended arguments (there can be bothselfandcls), and we would need the same construct not just forCallArgumentsbut also forCallArgumentTypes. At that point we're cloningVecDeques anyway, so the overhead of cloning the wholeVecDequewith all arguments didn't seem to justify the additional code complexity.Benchmarks
I see small performance improvements on this branch?! Maybe because we can run more things in parallel with less mutability?