-
-
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 methods that modify the network location #1316
Conversation
CodSpeed Performance ReportMerging #1316 will improve performances by 63.58%Comparing Summary
Benchmarks breakdown
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1316 +/- ##
=======================================
Coverage 95.94% 95.94%
=======================================
Files 27 27
Lines 5373 5378 +5
Branches 326 326
=======================================
+ Hits 5155 5160 +5
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. |
Reuses the same idea as aio-libs/yarl#1316 Calling tuple.__new__ is much faster because it avoids the extra runtime lambda https://github.com/python/cpython/blob/d83fcf8371f2f33c7797bc8f5423a8bca8c46e5c/Lib/collections/__init__.py#L441
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, (...)