From c56c84167f3c4c4c72139ed5c1174449686bea84 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 7 Aug 2023 14:25:10 +0300 Subject: [PATCH 1/2] gh-107710: Speed up `logging.getHandlerNames` function --- Lib/logging/__init__.py | 3 +-- .../Library/2023-08-07-14-24-42.gh-issue-107710.xfOCfj.rst | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2023-08-07-14-24-42.gh-issue-107710.xfOCfj.rst diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 46e86cb87ecfcb..a5f2c2f550c846 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -916,8 +916,7 @@ def getHandlerNames(): """ Return all known handler names as an immutable set. """ - result = set(_handlers.keys()) - return frozenset(result) + return frozenset(_handlers.keys()) class Handler(Filterer): diff --git a/Misc/NEWS.d/next/Library/2023-08-07-14-24-42.gh-issue-107710.xfOCfj.rst b/Misc/NEWS.d/next/Library/2023-08-07-14-24-42.gh-issue-107710.xfOCfj.rst new file mode 100644 index 00000000000000..70f8b58e7ff5f5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-08-07-14-24-42.gh-issue-107710.xfOCfj.rst @@ -0,0 +1 @@ +Speed up :func:`logging.getHandlerNames`. From bd4799fac23fed437f609acc0c1022443cd8c681 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 7 Aug 2023 14:59:13 +0300 Subject: [PATCH 2/2] Address review --- Lib/logging/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index a5f2c2f550c846..527fc5c631730a 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -916,7 +916,7 @@ def getHandlerNames(): """ Return all known handler names as an immutable set. """ - return frozenset(_handlers.keys()) + return frozenset(_handlers) class Handler(Filterer):