Skip to content
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 creating the ConnectionKey #9499

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Commits on Oct 18, 2024

  1. Improve performance of creating the ConnectionKey

    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.
    bdraco committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    8e2c4ec View commit details
    Browse the repository at this point in the history