-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Micro-optimize _to_rgba_no_colorcycle. #30020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f3f2c44
to
9dc9749
Compare
lib/matplotlib/colors.py
Outdated
return (*[n / 0xff for n in bytes.fromhex(c[1:])], | ||
alpha if alpha is not None else 1.) | ||
elif len(c) == 4: # #rgb hex format, shorthand for #rrggbb. | ||
return (*[int(n, 16) * 0x11 / 0xff for n in c[1:]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just ?
return (*[int(n, 16) * 0x11 / 0xff for n in c[1:]], | |
return (*[int(n, 16) / 0xf for n in c[1:]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah indeed, even better.
This patch speeds up conversions of `#rgba`-type formats by between 25% and 40% (while shortening the implementation), although real benefits should be limited because of caching in to_rgba.
@story645 Did you mean to close this? |
No sorry, my phone's been a little broken and I was probably looking at this on the app and accidentally closed it w/o noticing |
This patch speeds up conversions of
#rgba
-type formats by between 25% and 40% (while shortening the implementation), although real benefits should be limited because of caching in to_rgba.PR summary
PR checklist