Repository navigation
Conversation
|
@radarhere only downside as far as I can tell here is that the way this is cached requires a tuple allocation (as that is the key into the cache), besides of course the one off start/creation cost. LLM proposes changing to simply create all four cached byte arrays in one method , not sure if worth it. As far as I can tell runtime is about the same and still much faster than before. @cache
def _grayscale_palettes():
# Construct the four tables once.
return rgb_ramp, bgrx_ramp, rgb_monochrome, bgrx_monochrome
def _is_grayscale_palette(palette, colors, padding):
index = (2 if colors == 2 else 0) + padding - 3
return _grayscale_palettes()[index].startswith(palette) |
akx
left a comment
There was a problem hiding this comment.
Lgtm (sorry, been sick in bed all day). With the original method, every import of the BMP plugin (IOW, every import of Pillow) paid the memory price of all of the LUTs, so I think this is the better tradeoff.
|
Can we measure memory and speed? |
|
With the image from #10574 (comment), main shows There is no consistent difference with this PR. |
|
|
#10580 (comment)