diff options
author | Yonatan Goldschmidt <yon.goldschmidt@gmail.com> | 2021-05-25 22:40:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 22:40:23 (GMT) |
commit | 156699bca02dd2def844d03e26fc16a831336635 (patch) | |
tree | 5bc3e49bb2d4ffdde7252892c044eefc01071a9a /Lib/logging | |
parent | add805f92160fa2afbc8186b7a93d961ad2fe156 (diff) | |
download | cpython-156699bca02dd2def844d03e26fc16a831336635.zip cpython-156699bca02dd2def844d03e26fc16a831336635.tar.gz cpython-156699bca02dd2def844d03e26fc16a831336635.tar.bz2 |
bpo-44222: Improve _removeHandlerRef() for a very long _handlerList (GH-26325)
The list lookups become a big burden for very long lists.
This patch changes the "happy flow" path of 2 lookups into 1 lookup.
Automerge-Triggered-By: GH:vsajip
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 555f598..7865b71 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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() |