-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Improve performance of URL.with_scheme
#1322
Conversation
CodSpeed Performance ReportMerging #1322 will improve performances by 92.78%Comparing Summary
Benchmarks breakdown
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1322 +/- ##
=======================================
Coverage 95.96% 95.96%
=======================================
Files 27 27
Lines 5401 5403 +2
Branches 329 329
=======================================
+ Hits 5183 5185 +2
Misses 192 192
Partials 26 26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
URL.with_scheme
Reuses the same idea as aio-libs/yarl#1316 and aio-libs/yarl#1322 Calling `tuple.__new__` is much faster because it avoids the extra runtime lambda having to be run and arguments unpacked for every message https://github.com/python/cpython/blob/d83fcf8371f2f33c7797bc8f5423a8bca8c46e5c/Lib/collections/__init__.py#L441 This only works if the object being created is a `NamedTuple` so this speed up is only recommended internally and should not be used outside of `aiohttp` since we do not guarantee that ConnectionKey will remain a `NamedTuple` in the future.
Avoid calling
SplitResult._replace
since its much slower, and instead replace with fastNamedTuple
creationtuple.__new__(Type, (...)