[Python-checkins] bpo-44222: Improve _removeHandlerRef() for a very long _handlerList (GH-26325)
miss-islington
webhook-mailer at python.org
Tue May 25 18:40:31 EDT 2021
https://github.com/python/cpython/commit/156699bca02dd2def844d03e26fc16a831336635
commit: 156699bca02dd2def844d03e26fc16a831336635
branch: main
author: Yonatan Goldschmidt <yon.goldschmidt at gmail.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-05-25T15:40:23-07:00
summary:
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
files:
M Lib/logging/__init__.py
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 555f598de7a925..7865b71c8737b4 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()
More information about the Python-checkins
mailing list