Do not initialize image with zero dimension or when color is zero - #9957
Do not initialize image with zero dimension or when color is zero#9957radarhere wants to merge 2 commits into
Conversation
Merging this PR will degrade performance by 56.95%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | test_allocate[1237x811-L] |
1.1 ms | 2.5 ms | -56.95% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing radarhere:new_size (0f4e203) with main (7827507)
Footnotes
-
335 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
There was a problem hiding this comment.
I don't think this helps with the timeout on tall zero-width images.
core.fill(mode, size, color), paraphrased:
im = ImagingNewDirty(mode, xsize, ysize)ImagingFill(im, ink_parsed_from_color)return PyImagingNew(im)
core.new(mode, size), paraphrased:
im = ImagingNew(mode, xsize, ysize)return PyImagingNew(im)
ImagingNew and ImagingNewDirty are trampolines to ImagingNewInternal, which, paraphrased;
im = ImagingNewPrologue(mode, xsize, ysize);which callsImagingNewPrologueSubtype, which allocates the pointer array:im->image = (char **)calloc((ysize > 0) ? ysize : 1, sizeof(void *));
In fact, I think # don't initialize isn't a valid comment at all.
- EDIT: it hasn't been true for 7 to 13 years, depending, I investigated. #9960
#9933 mentioned that
Pillow/Tests/test_image.py
Lines 574 to 577 in 7827507
is intermittently failing on our CI.
I think
Pillow/src/PIL/Image.py
Lines 3234 to 3236 in 7827507
can be adjusted to help.