8000 bpo-44222: Improve _removeHandlerRef() for a very long _handlerList · python/cpython@7453857 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7453857

Browse files
committed
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.
1 parent 8b9310d commit 7453857

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/logging/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ def _removeHandlerRef(wr):
845845
if acquire and release and handlers:
846846
acquire()
847847
try:
848-
if wr in handlers:
849-
handlers.remove(wr)
848+
handlers.remove(wr)
849+
except ValueError:
850+
pass
850851
finally:
851852
release()
852853

0 commit comments

Comments
 (0)
0