Skip to content

Deprecate ImageQt align8to32() in favour of raw encoder stride - #9940

Merged
radarhere merged 2 commits into
python-pillow:mainfrom
akx:qt-speedup
Sep 4, 2026
Merged

Deprecate ImageQt align8to32() in favour of raw encoder stride#9940
radarhere merged 2 commits into
python-pillow:mainfrom
akx:qt-speedup

Conversation

@akx

@akx akx commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fell out of #9938 (namely 64507dc): the raw encoder had supported strides all along, but no one knew because it wasn't really documented in any way. For that reason, presumably, #1430 added a Python-side realigner.

This shows the old and new impls matching for a 113-pixel-wide Hopper, and what would happen if we don't align things:

2026-09-01_19-16-35

@radarhere

Copy link
Copy Markdown
Member

Hi. You're removing a public method. The preference would be to deprecate it instead.

@akx

akx commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@radarhere Sure. Adjusted to a deprecation.

Comment thread src/PIL/ImageQt.py Outdated
@radarhere

Copy link
Copy Markdown
Member

For the record, here's a link - https://doc.qt.io/qt-6/qimage.html

each scanline of data in the image must also be 32-bit aligned

@radarhere radarhere mentioned this pull request Sep 3, 2026
@radarhere

Copy link
Copy Markdown
Member

I'm guessing this improves performance?

@akx

akx commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I'm guessing this improves performance?

It does! +68% to +442% OPS for an image that wasn't correctly aligned on my box, ±10% (so measurement noise) for others. More than that, less memory allocations (as #9938 in general) since there isn't a temporary un-strided copy, temporary strided rows in a list, and finally a strided byte buffer, before the temporaries can be dropped.

@radarhere

Copy link
Copy Markdown
Member

I've created akx#23 with some suggestions.

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
@akx

akx commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased to fix conflicts in the .rst files and folded in the changes from review + suggestion PR.

@radarhere radarhere changed the title ImageQt: use raw encoder's stride parameter instead of doing it by hand ImageQt: use raw encoder's stride parameter Sep 4, 2026
@radarhere radarhere changed the title ImageQt: use raw encoder's stride parameter ImageQt: use raw encoder stride Sep 4, 2026
@radarhere radarhere added the Deprecation Feature that will be removed in the future label Sep 4, 2026
Comment thread docs/deprecations.rst Outdated
@radarhere radarhere changed the title ImageQt: use raw encoder stride Deprecate ImageQt align8to32() in favour of raw encoder stride Sep 4, 2026
@radarhere
radarhere merged commit 7827507 into python-pillow:main Sep 4, 2026
47 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deprecation Feature that will be removed in the future

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants