Skip to content

Commit 63a638c

Browse files
authored
gh-91349: Replace zlib with zlib-ng in Windows build (GH-131438)
1 parent c1a02f9 commit 63a638c

18 files changed

+1277
-38
lines changed

Doc/library/zlib.rst

+12
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@ the following constants:
330330
.. versionadded:: 3.3
331331

332332

333+
.. data:: ZLIBNG_VERSION
334+
335+
The version string of the zlib-ng library that was used for building the
336+
module if zlib-ng was used. When present, the :data:`ZLIB_VERSION` and
337+
:data:`ZLIB_RUNTIME_VERSION` constants reflect the version of the zlib API
338+
provided by zlib-ng.
339+
340+
If zlib-ng was not used to build the module, this constant will be absent.
341+
342+
.. versionadded:: 3.14
343+
344+
333345
.. seealso::
334346

335347
Module :mod:`gzip`

Doc/whatsnew/3.14.rst

+13
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ zipinfo
10261026
to produce reproducible output.
10271027
(Contributed by Jiahao Li in :gh:`91279`.)
10281028

1029+
10291030
.. Add improved modules above alphabetically, not here at the end.
10301031
10311032
Optimizations
@@ -1078,6 +1079,18 @@ uuid
10781079
(Contributed by Bénédikt Tran in :gh:`128150`.)
10791080

10801081

1082+
zlib
1083+
----
1084+
1085+
* On Windows, ``zlib-ng`` is now used as the implementation of the
1086+
:mod:`zlib` module. This should produce compatible and comparable
1087+
results with better performance, though it is worth noting that
1088+
``zlib.Z_BEST_SPEED`` (1) may result in significantly less
1089+
compression than the previous implementation (while also significantly
1090+
reducing the time taken to compress).
1091+
(Contributed by Steve Dower in :gh:`91349`.)
1092+
1093+
10811094
Deprecated
10821095
==========
10831096

Lib/test/pythoninfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def collect_zlib(info_add):
651651
except ImportError:
652652
return
653653

654-
attributes = ('ZLIB_VERSION', 'ZLIB_RUNTIME_VERSION')
654+
attributes = ('ZLIB_VERSION', 'ZLIB_RUNTIME_VERSION', 'ZLIBNG_VERSION')
655655
copy_attributes(info_add, zlib, 'zlib.%s', attributes)
656656

657657

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Replaces our copy of ``zlib`` with ``zlib-ng``, for performance improvements
2+
in :mod:`zlib`.

Misc/externals.spdx.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,25 @@
171171
"versionInfo": "5.2.5"
172172
},
173173
{
174-
"SPDXID": "SPDXRef-PACKAGE-zlib",
174+
"SPDXID": "SPDXRef-PACKAGE-zlib-ng",
175175
"checksums": [
176176
{
177177
"algorithm": "SHA256",
178-
"checksumValue": "e3f3fb32564952006eb18b091ca8464740e5eca29d328cfb0b2da22768e0b638"
178+
"checksumValue": "00bbd88709bc416cb96160ab61d3e1c8f76e106799af7328d0fe434dc7dd5004"
179179
}
180180
],
181-
"downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/zlib-1.3.1.tar.gz",
181+
"downloadLocation": "https://github.com/python/cpython-source-deps/archive/refs/tags/zlib-ng-2.2.4.tar.gz",
182182
"externalRefs": [
183183
{
184184
"referenceCategory": "SECURITY",
185-
"referenceLocator": "cpe:2.3:a:zlib:zlib:1.3.1:*:*:*:*:*:*:*",
185+
"referenceLocator": "cpe:2.3:a:zlib-ng:zlib-ng:2.2.4:*:*:*:*:*:*:*",
186186
"referenceType": "cpe23Type"
187187
}
188188
],
189189
"licenseConcluded": "NOASSERTION",
190-
"name": "zlib",
190+
"name": "zlib-ng",
191191
"primaryPackagePurpose": "SOURCE",
192-
"versionInfo": "1.3.1"
192+
"versionInfo": "2.2.4"
193193
}
194194
],
195195
"spdxVersion": "SPDX-2.3"

Modules/zlibmodule.c

+6
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,12 @@ zlib_exec(PyObject *mod)
21012101
PyUnicode_FromString(zlibVersion())) < 0) {
21022102
return -1;
21032103
}
2104+
#ifdef ZLIBNG_VERSION
2105+
if (PyModule_Add(mod, "ZLIBNG_VERSION",
2106+
PyUnicode_FromString(ZLIBNG_VERSION)) < 0) {
2107+
return -1;
2108+
}
2109+
#endif
21042110
if (PyModule_AddStringConstant(mod, "__version__", "1.0") < 0) {
21052111
return -1;
21062112
}

0 commit comments

Comments
 (0)