summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorYonatan Goldschmidt <yon.goldschmidt@gmail.com>2021-05-25 22:40:23 (GMT)
committerGitHub <noreply@github.com>2021-05-25 22:40:23 (GMT)
commit156699bca02dd2def844d03e26fc16a831336635 (patch)
tree5bc3e49bb2d4ffdde7252892c044eefc01071a9a /Lib/logging
parentadd805f92160fa2afbc8186b7a93d961ad2fe156 (diff)
downloadcpython-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__.py5
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()