-
Notifications
You must be signed in to change notification settings - Fork 280
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
PERF: reduce startup overhead from cmap registration #4538
Conversation
f6ee3a3
to
857f300
Compare
2b5153e
to
24ad119
Compare
from matplotlib.colors import LinearSegmentedColormap | ||
|
||
issue_deprecation_warning( | ||
"yt.visualization.color_maps.add_colormap is deprecated", |
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.
what is it being replaced with?
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.
nothing, it's not strictly needed !
try: | ||
add_colormap(k, cdict) | ||
mpl.colormaps.register(ListedColormap(v, name=k, N=256)) |
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.
I mean, this is slightly flatter, but I don't think it's a big deal, either.
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.
yeah, this PR yields disappointing results, but just in case, I want to clarify that the gain here is not expected to come from the inlining, but from instantiating ListedColormap
instead of LinearSegmentedColormap
, which saves a conversion from the format we actually define our maps in.
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.
cmap.name = hist_name | ||
mpl.colormaps.register(cmap) | ||
mpl.colormaps.register(cmap.reversed()) | ||
cmap = mpl.colormaps[alias] |
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.
note for later that this even if we close this PR, this line change is worth using if only because mpl.colormaps.__getitem__
already returns copies, so the current implementation of this line is unjustified.
24ad119
to
b87982f
Compare
I'll drop this (again) because it's far too big a patch for such a small gain. I'll reopen a much smaller PR with just the simplest avoid-double-copies patch (which impacts 2 lines) |
PR Summary
another, maybe more aggressive attempt at minimising startup overhead from colormaps registration (2nd take following #4520)