Skip to content

Speed up ImageChops operations#9738

Open
akx wants to merge 1 commit into
python-pillow:mainfrom
akx:faster-chops
Open

Speed up ImageChops operations#9738
akx wants to merge 1 commit into
python-pillow:mainfrom
akx:faster-chops

Conversation

@akx

@akx akx commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Refs #9649, #9675, #9736, #9737 (same series, same techniques).

@akx akx changed the title Chops: hoist size vars and add restrict in CHOP/CHOP2 macros Speed up ImageChops operations Jun 30, 2026
@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 95.74%

⚠️ 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

⚡ 36 improved benchmarks
✅ 295 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_chops[1024x1024-RGBA-add_modulo] 18.6 ms 6.5 ms ×2.8
test_chops[1024x1024-LA-add_modulo] 18.6 ms 6.5 ms ×2.8
test_chops[1024x1024-RGB-add_modulo] 18.6 ms 6.5 ms ×2.8
test_chops[1024x1024-L-add_modulo] 4.7 ms 1.7 ms ×2.8
test_chops[1024x1024-LA-darker] 26.8 ms 11 ms ×2.4
test_chops[1024x1024-LA-lighter] 26.8 ms 11 ms ×2.4
test_chops[1024x1024-RGBA-lighter] 26.8 ms 11 ms ×2.4
test_chops[1024x1024-RGBA-darker] 26.8 ms 11 ms ×2.4
test_chops[1024x1024-RGB-darker] 26.8 ms 11 ms ×2.4
test_chops[1024x1024-RGB-lighter] 26.8 ms 11 ms ×2.4
test_chops[1024x1024-L-lighter] 6.7 ms 2.8 ms ×2.4
test_chops[1024x1024-L-darker] 6.7 ms 2.8 ms ×2.4
test_chops[1024x1024-LA-add] 32.6 ms 14.1 ms ×2.3
test_chops[1024x1024-RGBA-add] 32.6 ms 14.1 ms ×2.3
test_chops[1024x1024-RGB-add] 32.6 ms 14.1 ms ×2.3
test_chops[1024x1024-L-add] 8.2 ms 3.6 ms ×2.3
test_chops[1024x1024-RGBA-subtract] 29.1 ms 14.4 ms ×2
test_chops[1024x1024-LA-subtract] 29.1 ms 14.4 ms ×2
test_chops[1024x1024-RGB-subtract] 29.1 ms 14.4 ms ×2
test_chops[1024x1024-L-subtract] 7.3 ms 3.7 ms ×2
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

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-chops (29314c7) with main (e234120)

Open in CodSpeed

@akx akx marked this pull request as ready for review June 30, 2026 08:36
@akx

akx commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I don't think the Tests.test_file_avif.TestAvifLeaks test failure on 3.15t is related to this patch 😅

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.

3 participants