| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@terryjreedy as the reviewer of the related PR, could you share thoughts on this matter? Thanks! |
Sorry, something went wrong.
There was a problem hiding this comment.
minc == maxc and sumc == 2.0 are checking for the same thing - preventing division by zero. Another possible fix would be to check if l==1 on line 91.
Sorry, something went wrong.
|
@gaogaotiantian Thank you for finding the change that caused the regression (which I merged, not just reviewed). As explained on this issue, the fix is incorrect. I am preparing a new PR with a different test addition. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
colorsys.rgb_to_hls(1, 1, 0.9999999999999999) raises ZeroDivisionError now (this probably is the ONLY case). Not sure if it's worth fixing, but I think "correct" in all cases is more important than "very slightly faster in theory".
This optimization is originally introduced in #23306, using the benchmark given in the PR, there's no observable performance regression with the extra check.
Benchmark CodeAnother possible implementation is to do a try-except block for the division. As try is almost no cost now, it would be theoretically faster than the current one. The return value would be different (a near white color can be represented in many forms in hls space). I prefer the current solution as it's easy to understand with the comment, but I do not oppose the other way.