Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rewrap
  • Loading branch information
hugovk committed May 6, 2025
commit 0cff9a68274a5d2089a8c12fd8dedc6a305c62de
35 changes: 20 additions & 15 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,22 @@ See :pep:`768` for more details.
PEP 784: Adding Zstandard to the standard library
-------------------------------------------------

The new ``compression`` package contains modules :mod:`!compression.lzma`, :mod:`!compression.bz2`,
:mod:`!compression.gzip` and :mod:`!compression.zlib` which re-export the :mod:`lzma`, :mod:`bz2`,
:mod:`gzip` and :mod:`zlib` modules respectively. The new import names under ``compression`` are
the canonical names for importing these compression modules going forward. However, the existing
modules names have not been deprecated. Any deprecation or removal of the existing compression modules
will occur no sooner than five years after the release of 3.14.

The new :mod:`!compression.zstd` module provides compression and decompression APIs for the
Zstandard format via bindings to `Meta's zstd library <https://facebook.github.io/zstd/>`__.
Zstandard is a widely adopted, highly efficient, and fast compression format. In addition to the APIs
introduced in :mod:`!compression.zstd`, support for reading and writing Zstandard compressed archives
has been added to the :mod:`tarfile`, :mod:`zipfile`, and :mod:`shutil` modules.
The new ``compression`` package contains modules :mod:`!compression.lzma`,
:mod:`!compression.bz2`, :mod:`!compression.gzip` and :mod:`!compression.zlib`
which re-export the :mod:`lzma`, :mod:`bz2`, :mod:`gzip` and :mod:`zlib`
modules respectively. The new import names under ``compression`` are the
canonical names for importing these compression modules going forward. However,
the existing modules names have not been deprecated. Any deprecation or removal
of the existing compression modules will occur no sooner than five years after
the release of 3.14.

The new :mod:`!compression.zstd` module provides compression and decompression
APIs for the Zstandard format via bindings to `Meta's zstd library
<https://facebook.github.io/zstd/>`__. Zstandard is a widely adopted, highly
efficient, and fast compression format. In addition to the APIs introduced in
:mod:`!compression.zstd`, support for reading and writing Zstandard compressed
archives has been added to the :mod:`tarfile`, :mod:`zipfile`, and
:mod:`shutil` modules.

Here's an example of using the new module to compress some data:

Expand All @@ -265,10 +269,11 @@ Here's an example of using the new module to compress some data:
ratio = len(compressed) / len(data)
print(f"Achieved compression ratio of {ratio}")

As can be seen, the API is similar to the APIs of the :mod:`!lzma` and :mod:`!bz2` modules.
As can be seen, the API is similar to the APIs of the :mod:`!lzma` and
:mod:`!bz2` modules.

(Contributed by Emma Harper Smith, Adam Turner, Gregory P. Smith, Tomas R., Victor Stinner, and
Rogdham in :gh:`132983`)
(Contributed by Emma Harper Smith, Adam Turner, Gregory P. Smith, Tomas R.,
Victor Stinner, and Rogdham in :gh:`132983`)

.. seealso::
:pep:`768`.
Expand Down