From b1d155f49ab42981219537990cc1e233e454b5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Marinier?= Date: Fri, 1 Sep 2023 16:42:31 +0200 Subject: [PATCH 1/3] Small performance improvement of getproxies_environment() when there are many environment variables. In a benchmark with 5k environment variables not related to proxies, and 5 specifying proxies, we get a 10% walltime improvement. --- Lib/urllib/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 1d03259b918c33..bca594420f6d9d 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2490,7 +2490,7 @@ def getproxies_environment(): # select only environment variables which end in (after making lowercase) _proxy proxies = {} environment = [] - for name in os.environ.keys(): + for name in os.environ: # fast screen underscore position before more expensive case-folding if len(name) > 5 and name[-6] == "_" and name[-5:].lower() == "proxy": value = os.environ[name] From 0e43950822b929b9e2a40734cce29ec6def352ce Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 15:33:19 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst diff --git a/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst b/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst new file mode 100644 index 00000000000000..0d5ff993139b4a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst @@ -0,0 +1 @@ +Small (10 - 20%) and trivial performance improvement of urrlib.request.getproxies_environment(), typically useful when there are many environment variables to go over. From 74f8537013047294d77f4e3c7832e9d4ff02f7b4 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sun, 17 Sep 2023 17:45:24 -0700 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst Co-authored-by: Pieter Eendebak --- .../next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst b/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst index 0d5ff993139b4a..a1af479459d755 100644 --- a/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst +++ b/Misc/NEWS.d/next/Library/2023-09-01-15-33-18.gh-issue-91539.xoNLEI.rst @@ -1 +1 @@ -Small (10 - 20%) and trivial performance improvement of urrlib.request.getproxies_environment(), typically useful when there are many environment variables to go over. +Small (10 - 20%) and trivial performance improvement of :func:`urrlib.request.getproxies_environment`, typically useful when there are many environment variables to go over.