Skip to content

Speed up Image.getextrema()#9762

Open
akx wants to merge 5 commits into
python-pillow:mainfrom
akx:extremaly-fast
Open

Speed up Image.getextrema()#9762
akx wants to merge 5 commits into
python-pillow:mainfrom
akx:extremaly-fast

Conversation

@akx

@akx akx commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Speeds up getextrema() -- with more than just hoist and restrict this time, by adding a separate function for the common case of 2-4 band 8bpc images. The single-channel case speeds up pleasantly too by autovectorisation, though.

------------------- benchmark 'extrema': 4 tests, 2 sources --------------------
Name (time in us)                   0001_3a36c3a OPS  0003_796ae94 OPS      ΔOPS
--------------------------------------------------------------------------------
test_getextrema[1024x1024-RGB]            1,790.4542       13,099.6057   +631.6%
test_getextrema[1024x1024-L]              1,410.9957       17,641.2525  +1150.3%
test_getextrema[1024x1024-RGBA]             687.5769       13,102.1316  +1805.6%
test_getextrema[1024x1024-LA]               494.9731       11,851.6516  +2294.4%
--------------------------------------------------------------------------------

akx

This comment was marked as outdated.

Co-authored-by: Aarni Koskela <akx@iki.fi>
@akx akx marked this pull request as ready for review July 4, 2026 10:54
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