@@ -3,12 +3,13 @@ Title: Adding Zstandard to the standard library
3
3
Author: Emma Harper Smith <
[email protected] >
4
4
Sponsor: Gregory P. Smith <
[email protected] >
5
5
Discussions-To: https://discuss.python.org/t/87377
6
- Status: Draft
6
+ Status: Accepted
7
7
Type: Standards Track
8
8
Created: 06-Apr-2025
9
9
Python-Version: 3.14
10
10
Post-History:
11
11
`07-Apr-2025 <https://discuss.python.org/t/87377 >`__,
12
+ Resolution: `25-Apr-2025 <https://discuss.python.org/t/87377/138 >`__
12
13
13
14
14
15
Abstract
@@ -115,9 +116,8 @@ Both the ``zstd`` and ``zstandard`` import names are claimed by projects on
115
116
PyPI. To avoid breaking users of one of the existing bindings, this PEP
116
117
proposes introducing a new namespace for compression libraries,
117
118
``compression ``. This name is already reserved on PyPI for use in the
118
- standard library. The new Zstandard module will be ``compression.zstd ``.
119
- Other compression modules will be re-exported to the ``compression `` namespace
120
- and their current import names will be deprecated.
119
+ standard library. The new Zstandard module will be named ``compression.zstd ``.
120
+ Other compression modules will be re-exported in the new ``compression `` package.
121
121
122
122
Providing a common namespace for compression modules has several advantages.
123
123
First, it reduces user confusion about where to find compression modules.
@@ -220,38 +220,25 @@ Other compression modules
220
220
New import names ``compression.lzma ``, ``compression.bz2 ``,
221
221
``compression.gzip `` and ``compression.zlib `` will be introduced in Python 3.14
222
222
re-exporting the contents of the existing ``lzma ``, ``bz2 ``, ``gzip `` and
223
- ``zlib `` modules respectively.
223
+ ``zlib `` modules respectively. The ``compression `` sub-modules will become
224
+ the canonical import names going forward. The use of the new compression names
225
+ will be promoted over the original top level module names in the Python
226
+ documentation when the minimum supported Python version requirements make
227
+ that feasible.
224
228
225
229
The ``_compression `` module, given that it is marked private, will be
226
- immediately renamed to ``compression._common.streams ``. The new name was
230
+ immediately renamed to ``compression._common._streams ``. The new name was
227
231
selected due to the current contents of the module being I/O related helpers
228
232
for stream APIs (e.g. ``LZMAFile ``) in standard library compression modules.
229
233
230
- Compression module migration timeline
231
- -------------------------------------
232
-
233
- Existing modules will emit a ``DeprecationWarning `` in the Python
234
- release following the last Python without the ``compression `` module leaving
235
- support. For example, if the ``compression `` namespace is introduced in 3.14,
236
- then the ``DeprecationWarnings `` would be emitted in 3.19, the next release
237
- after 3.13 reaches end of life. These warnings would begin five years after the
238
- introduction of ``compression `` namespace. In accordance with :pep: `387 `, in
239
- Python 3.24, five years after the ``DeprecationWarnings `` are added and ten
240
- years after the new ``compression `` namespace is introduced, the existing
241
- modules will be removed and code must use the ``compression `` sub-modules. The
242
- documentation for these modules will be updated to discuss the planned
243
- deprecation and removal timelines.
244
-
245
234
246
235
Backwards Compatibility
247
236
=======================
248
237
249
- The main compatibility concern is usage of existing standard library
250
- compression APIs with the existing import names. These names will be
251
- deprecated in 3.19 and will be removed in 3.24. Given the long coexistence of
252
- the modules and a 5 year deprecation period, most users will likely migrate to
253
- the new import names well before then. Additionally, a libCST codemod can be
254
- provided to automatically rewrite imports, easing the migration.
238
+ This PEP introduces no backwards incompatible changes. There are currently no
239
+ plans to deprecate or remove the existing compression modules. Any deprecation
240
+ or removal of the existing modules is left to a future decision but will occur
241
+ no sooner than 5 years from the acceptance of this PEP.
255
242
256
243
257
244
Security Implications
@@ -273,8 +260,8 @@ How to Teach This
273
260
=================
274
261
275
262
Documentation for the new module is in the reference implementation branch. The
276
- documentation for other modules will be updated to discuss the deprecation of
277
- their existing import names, and how to migrate .
263
+ documentation for existing modules will be updated to reference the new names
264
+ as well .
278
265
279
266
280
267
Reference Implementation
@@ -284,8 +271,7 @@ The `reference implementation <https://github.com/emmatyping/cpython/tree/zstd>`
284
271
contains the ``_zstd `` C code, the ``compression.zstd `` code, modifications to
285
272
``tarfile ``, ``shutil ``, and ``zipfile ``, and tests for each new API and
286
273
integration added. It also contains the re-exports of other compression
287
- modules. Deprecations for the existing import names will be added once a
288
- decision is reached regarding the open issues.
274
+ modules.
289
275
290
276
291
277
Rejected Ideas
0 commit comments