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

Skip to content
8000

Commit 156699b

Browse files
authored
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
1 parent add805f commit 156699b

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)
< 5714 code>848+
handlers.remove(wr)
849+
except ValueError:
850+
pass
850851
finally:
851852
release()
852853

0 commit comments

Comments
 (0)
0