8000 bpo-44222: Improve _removeHandlerRef() for a very long _handlerList by Jongy · Pull Request #26325 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44222: Improve _removeHandlerRef() for a very long _handlerList #26325

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

Merged
merged 3 commits into from
May 25, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-44222: Improve _removeHandlerRef() for a very long _handlerList
The list lookups become a big burden for very long lists.
This patch changes the "happy flow" path of 2 lookups into 1 lookup.
  • Loading branch information
Jongy committed May 24, 2021
commit 7453857c715fd318f230ab865c881e8b245c88e3
5 changes: 3 additions & 2 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,9 @@ def _removeHandlerRef(wr):
if acquire and release and handlers:
acquire()
try:
if wr in handlers:
handlers.remove(wr)
handlers.remove(wr)
except ValueError:
pass
finally:
release()

Expand Down
0