@@ -3,12 +3,13 @@ Title: Adding Zstandard to the standard library
33Author: Emma Harper Smith <emma@python.org>
44Sponsor: Gregory P. Smith <greg@krypto.org>
55Discussions-To: https://discuss.python.org/t/87377
6- Status: Draft
6+ Status: Accepted
77Type: Standards Track
88Created: 06-Apr-2025
99Python-Version: 3.14
1010Post-History:
1111 `07-Apr-2025 <https://discuss.python.org/t/87377 >`__,
12+ Resolution: `25-Apr-2025 <https://discuss.python.org/t/87377/138 >`__
1213
1314
1415Abstract
@@ -115,9 +116,8 @@ Both the ``zstd`` and ``zstandard`` import names are claimed by projects on
115116PyPI. To avoid breaking users of one of the existing bindings, this PEP
116117proposes introducing a new namespace for compression libraries,
117118``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.
121121
122122Providing a common namespace for compression modules has several advantages.
123123First, it reduces user confusion about where to find compression modules.
@@ -220,38 +220,25 @@ Other compression modules
220220New import names ``compression.lzma ``, ``compression.bz2 ``,
221221``compression.gzip `` and ``compression.zlib `` will be introduced in Python 3.14
222222re-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.
224228
225229The ``_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
227231selected due to the current contents of the module being I/O related helpers
228232for stream APIs (e.g. ``LZMAFile ``) in standard library compression modules.
229233
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-
245234
246235Backwards Compatibility
247236=======================
248237
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.
255242
256243
257244Security Implications
@@ -273,8 +260,8 @@ How to Teach This
273260=================
274261
275262Documentation 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 .
278265
279266
280267Reference Implementation
@@ -284,8 +271,7 @@ The `reference implementation <https://github.com/emmatyping/cpython/tree/zstd>`
284271contains the ``_zstd `` C code, the ``compression.zstd `` code, modifications to
285272``tarfile ``, ``shutil ``, and ``zipfile ``, and tests for each new API and
286273integration 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.
289275
290276
291277Rejected Ideas
0 commit comments