-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[red-knot] Refactor: no mutability in call APIs #17788
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
Conversation
|
450a150 to
7ddc065
Compare
AlexWaygood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this seems cleaner for sure. Definitely worth it if perf is neutral/slightly better.
|
Could also be worth running the |
|
Inconclusive (no statistically significant improvement/regression)
|
| F: FnOnce(&mut Self) -> R, | ||
| F: FnOnce(&Self) -> R, | ||
| { | ||
| let mut call_arguments = self.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
* 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)
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?