From 089426893d65ce0b96d8480696dd9f3b0ea738cc Mon Sep 17 00:00:00 2001 From: Yay295 Date: Wed, 2 Oct 2024 00:14:54 -0500 Subject: [PATCH 1/3] inline variables, combining divisions --- Lib/colorsys.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib/colorsys.py b/Lib/colorsys.py index e97f91718a3a30..677ba741ab790e 100644 --- a/Lib/colorsys.py +++ b/Lib/colorsys.py @@ -130,15 +130,12 @@ def rgb_to_hsv(r, g, b): if minc == maxc: return 0.0, 0.0, v s = rangec / maxc - rc = (maxc-r) / rangec - gc = (maxc-g) / rangec - bc = (maxc-b) / rangec if r == maxc: - h = bc-gc + h = (g-b) / rangec elif g == maxc: - h = 2.0+rc-bc + h = 2.0 + (b-r) / rangec else: - h = 4.0+gc-rc + h = 4.0 + (r-g) / rangec h = (h/6.0) % 1.0 return h, s, v From 6bb2bbe44761dcbed954170b9d8cdc38b62a7fc6 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:47:46 +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/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst diff --git a/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst b/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst new file mode 100644 index 00000000000000..63572763b97acb --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst @@ -0,0 +1 @@ +`colorsys.rgb_to_hsv` has been slightly optimized. From c48c44b40644608bd719445509a8379a8c9e42b2 Mon Sep 17 00:00:00 2001 From: Yay295 Date: Wed, 2 Oct 2024 12:03:41 -0500 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst Co-authored-by: Tian Gao --- .../next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst b/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst index 63572763b97acb..fa679ba0c6f198 100644 --- a/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst +++ b/Misc/NEWS.d/next/Library/2024-10-02-16-47-45.gh-issue-124879.9m2Wmx.rst @@ -1 +1 @@ -`colorsys.rgb_to_hsv` has been slightly optimized. +Optimized :func:`colorsys.rgb_to_hsv` to reduce the number of operations.