Skip to content

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

Merged
methane merged 8 commits into
python:mainfrom
bdraco:selectors_add_reader_perf
Jul 13, 2023
Merged

gh-106664: selectors: add get method to _SelectorMapping#106665
methane merged 8 commits into
python:mainfrom
bdraco:selectors_add_reader_perf

Conversation

@bdraco

@bdracobdraco commented Jul 12, 2023

Copy link
Copy Markdown
Contributor

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
@methanemethane changed the title gh-106664: Reduce overhead to add new selectorsgh-106664: selectors: add get method to _SelectorMappingJul 12, 2023
Comment threadLib/selectors.py Outdated
Comment threadLib/selectors.py
Comment threadMisc/NEWS.d/next/Library/2023-07-12-03-04-45.gh-issue-106664.ZeUG78.rst Outdated
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Comment threadMisc/NEWS.d/next/Library/2023-07-12-03-04-45.gh-issue-106664.ZeUG78.rst Outdated
Comment threadMisc/NEWS.d/next/Library/2023-07-12-03-04-45.gh-issue-106664.ZeUG78.rst Outdated
@methane
methane enabled auto-merge (squash) July 13, 2023 18:54
@bdraco

Copy link
Copy Markdown
ContributorAuthor

Thank you

@methane
methane merged commit 8d2f3c3 into python:mainJul 13, 2023
@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 freeto 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.

3 participants

@bdraco@methane@bedevere-bot