Skip to content

Speed up Image.filter() for I;16*#9760

Draft
akx wants to merge 6 commits into
python-pillow:mainfrom
akx:faster-filter-still
Draft

Speed up Image.filter() for I;16*#9760
akx wants to merge 6 commits into
python-pillow:mainfrom
akx:faster-filter-still

Conversation

@akx

@akx akx commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Follows up on #8438; same split-by-mode optimization technique as in #9737.

Also fixes up things around ImageFilter:

  • the tests' modes list was N-plicated
  • the test_consistency_* tests didn't use the mode parametrization at all and just ran the same test N times
  • test_crash claimed ImageFilter would crash on images smaller than the kernel; it doesn't, it just returns the same image.
    • Looks like test_crash had had assert_no_exception sometime before 3ec5059?
  • The docstring for Kernel claimed only a couple of modes were supported.

@codspeed-hq

codspeed-hq Bot commented Jul 3, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×2.4

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 343 untouched benchmarks
⏩ 2 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
test_filter[1024x1024-L-Smooth] 24.3 ms 10.1 ms ×2.4
test_filter[1024x1024-L-Sharpen] 24.2 ms 10.1 ms ×2.4

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing akx:faster-filter-still (525c545) with main (1cf685c)

Open in CodSpeed

Footnotes

  1. 2 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.

@akx

This comment was marked as outdated.

@akx akx force-pushed the faster-filter-still branch 2 times, most recently from 80ed36b to e2022ed Compare July 3, 2026 16:27
@akx akx force-pushed the faster-filter-still branch from e2022ed to 525c545 Compare July 3, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants