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

gh-106664: selectors: add get method to _SelectorMapping #106665

Merged
merged 8 commits into from Jul 13, 2023

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Jul 12, 2023

Avoids raising and catching KeyError twice every time a new reader is added

The overall goal is to reduce latency and time to first byte
related #106527 related #106554

Avoids raising and catching KeyError twice
@bdraco bdraco marked this pull request as ready for review July 12, 2023 05:58
@methane methane changed the title gh-106664: Reduce overhead to add new selectors gh-106664: selectors: add get method to _SelectorMapping Jul 12, 2023
Lib/selectors.py Outdated Show resolved Hide resolved
Lib/selectors.py Show resolved Hide resolved
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
@methane methane enabled auto-merge (squash) July 13, 2023 18:54
@bdraco
Copy link
Contributor Author

bdraco commented Jul 13, 2023

Thank you

@methane methane merged commit 8d2f3c3 into python:main Jul 13, 2023
20 of 21 checks passed
@bdraco bdraco deleted the selectors_add_reader_perf branch July 13, 2023 19:21
kgdiem pushed a commit to kgdiem/cpython that referenced this pull request Jul 14, 2023
…hon#106665)

It can be used to avoid raising and catching KeyError twice via __getitem__.

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
bdraco added a commit to bdraco/async_upnp_client that referenced this pull request Aug 13, 2023
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
bdraco added a commit to bdraco/async_upnp_client that referenced this pull request Aug 13, 2023
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
bdraco added a commit to bdraco/async_upnp_client that referenced this pull request Aug 13, 2023
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
bdraco added a commit to bdraco/async_upnp_client that referenced this pull request Aug 13, 2023
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
bdraco added a commit to bdraco/async_upnp_client that referenced this pull request Aug 13, 2023
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
bdraco added a commit to bdraco/async_upnp_client that referenced this pull request Aug 13, 2023
get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
StevenLooman pushed a commit to StevenLooman/async_upnp_client that referenced this pull request Aug 13, 2023
* Implement get on CaseInsensitiveDict

get was previously provided by the parent class which
had to raise KeyError for missing values. Since try/except
is only cheap for the non-exception case the performance
was not good when the key was missing

similar to python/cpython#106665
but in the HA case we call this even more frequently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants