-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use zlib-ng instead of zlib #8500
base: main
Are you sure you want to change the base?
Conversation
zlib-ng v2.2.2 x86_64-compat was not released because of CI test error. It'll be released at next version again. Anyway, building with CMake is also a fine solution. I'll follow Pillow devs' decision and close my PR #8495 when it's decided. |
Here's a chart of the write times for different compression levels and images:
Summary: zlib-ng is much faster. And file sizes:
Summary: zlib-ng has same file sizes for compression level 0 and bigger files for compression level 1, but if you care about size, any higher compression level gives more or less the same file size (and zlib-ng is faster). |
I've now checked that the Windows arm64 wheels pass the test suite on an MacBook Pro M2 Max (tested Python versions: 3.9.10, 3.10.11, 3.11.6, 3.12.0, 3.13.0). Benchmark results comparing the Python 3.13 wheels of the 11.0.0 release and the pull request build (click to expand)
|
"license": "LICENSE.md", | ||
"patch": { | ||
r"CMakeLists.txt": { | ||
"set_target_properties(zlib PROPERTIES OUTPUT_NAME zlibstatic${{SUFFIX}})": "set_target_properties(zlib PROPERTIES OUTPUT_NAME zlib)", # noqa: E501 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If zlib-ng creates zlibstatic.lib by default, then wouldn't it seem helpful to detect that in setup.py, in case a user had built it themselves? nulano#44
Alternative to #8495 .
Changes proposed in this pull request:
Replace zlib with zlib-ng built with CMake in Windows builds. Building our own zlib-ng allows us to use the latest release since the zlib-ng 2.2.2 release is missing the x86_64 Windows build.
Add a flag to
PIL.features
for zlib-ng.python3 -m PIL.report
now looks like this:I took inspiration from #8495 (comment) to make a benchmark with multiple compression values. It seems that zlib-ng usually produces a slightly larger file but in much less time during compression.
Script and results (click to expand)
Looking at the build logs, zlib-ng seems to have been properly detected by webp, libtiff, libpng, and freetype.
TODO: