Skip to content

gh-NNNNNN: Improve colorsys module code quality#148878

Closed
KirobotDev wants to merge 2 commits intopython:mainfrom
KirobotDev:main
Closed

gh-NNNNNN: Improve colorsys module code quality#148878
KirobotDev wants to merge 2 commits intopython:mainfrom
KirobotDev:main

Conversation

@KirobotDev
Copy link
Copy Markdown

Summary

Minor code quality improvements in
[Lib/colorsys.py](https://github.com/python/cpython/blob/main/Lib/colorsys.py):

  • Simplified value clamping in yiq_to_rgb() using min() / max() instead of 6 if-blocks
  • Replaced chain of if-statements in hsv_to_rgb() with a lookup table (tuple of tuples)
  • Added spaces around modulo operator for consistency (i % 6 instead of i%6)

Changes

  • Before: 167 lines with verbose control flow
  • After: 154 lines, more Pythonic and readable

No functional changes — all existing behavior preserved.

Links

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 22, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 22, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 22, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Apr 22, 2026

This is code churn, sorry but we do not accept such changes.

@picnixz picnixz closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants