From 3d354e775e690dffac7634dfcf2ac678a1513532 Mon Sep 17 00:00:00 2001 From: Emma Harper Smith Date: Mon, 5 May 2025 23:15:38 -0700 Subject: [PATCH 1/6] Add What's New entry for PEP 784 implementation This covers both the compression package and compression.zstd. --- Doc/whatsnew/3.14.rst | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 8f427fff76b0ba..a7ca2ac4895148 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -71,6 +71,7 @@ Summary -- release highlights * :ref:`PEP 761: Discontinuation of PGP signatures ` * :ref:`PEP 765: Disallow return/break/continue that exit a finally block ` * :ref:`PEP 768: Safe external debugger interface for CPython ` +* :ref:`PEP 784: Adding Zstandard to the standard library ` * :ref:`A new type of interpreter ` * :ref:`Syntax highlighting in PyREPL `, and color output in :ref:`unittest `, @@ -232,6 +233,44 @@ See :pep:`768` for more details. (Contributed by Pablo Galindo Salgado, Matt Wozniski, and Ivona Stojanovic in :gh:`131591`.) +.. _whatsnew314-pep784: + +PEP 784: Adding Zstandard to the standard library +------------------------------------------------- + +The new ``compression`` package contains modules ``compression.lzma``, ``compression.bz2``, +``compression.gzip`` and ``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 5 years after the release of 3.14. + +The new ``compression.zstd`` module provides compression and decompression APIs for the +Zstandard format via bindings to `Meta's zstd library `__. +Zstandard is a widely adopted, highly efficient, and fast compression format. In addition to the APIs +introduced in ``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: + +.. code-block:: python + + from compression import zstd + import math + + data = str(math.pi).encode() * 20 + + compressed = zstd.compress(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. + +See :pep:`784` for more details. + +(Contributed by Emma Harper Smith, Adam Turner, Gregory P. Smith, Tomas R., Victor Stinner, and +Rogdham in :gh:`132983`) .. _whatsnew314-remote-pdb: From df329f48233b88bc846799b9ae08647e7b63750d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 6 May 2025 09:43:34 +0300 Subject: [PATCH 2/6] Use roles for consitent formatting --- Doc/whatsnew/3.14.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index a7ca2ac4895148..7b3ed1f1cf98b7 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -238,17 +238,17 @@ See :pep:`768` for more details. PEP 784: Adding Zstandard to the standard library ------------------------------------------------- -The new ``compression`` package contains modules ``compression.lzma``, ``compression.bz2``, -``compression.gzip`` and ``compression.zlib`` which re-export the :mod:`lzma`, :mod:`bz2`, +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 5 years after the release of 3.14. -The new ``compression.zstd`` module provides compression and decompression APIs for the +The new :mod:`!compression.zstd` module provides compression and decompression APIs for the Zstandard format via bindings to `Meta's zstd library `__. Zstandard is a widely adopted, highly efficient, and fast compression format. In addition to the APIs -introduced in ``compression.zstd``, support for reading and writing Zstandard compressed archives +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: From 95f64350184d59f9192b4e9eb37679c8e41232d1 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 6 May 2025 09:44:02 +0300 Subject: [PATCH 3/6] Use seealso directive --- Doc/whatsnew/3.14.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 7b3ed1f1cf98b7..02e0fddcee19aa 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -267,11 +267,13 @@ Here's an example of using the new module to compress some data: As can be seen, the API is similar to the APIs of the :mod:`!lzma` and :mod:`!bz2` modules. -See :pep:`784` for more details. - (Contributed by Emma Harper Smith, Adam Turner, Gregory P. Smith, Tomas R., Victor Stinner, and Rogdham in :gh:`132983`) +.. seealso:: + :pep:`768`. + + .. _whatsnew314-remote-pdb: Remote attaching to a running Python process with PDB From 883ed235887fcba78ad16aea8c7d31fb15e921f5 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 6 May 2025 09:44:36 +0300 Subject: [PATCH 4/6] 5 -> five --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 02e0fddcee19aa..f6c518e2357bec 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -243,7 +243,7 @@ The new ``compression`` package contains modules :mod:`!compression.lzma`, :mod: :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 5 years after the release of 3.14. +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 `__. From 0cff9a68274a5d2089a8c12fd8dedc6a305c62de Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 6 May 2025 09:45:54 +0300 Subject: [PATCH 5/6] Rewrap --- Doc/whatsnew/3.14.rst | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index f6c518e2357bec..5767daa60036a9 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -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 `__. -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 +`__. 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: @@ -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`. From 21e6e312cae0eabe7670c4674dfbda4abaf1bbb7 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 6 May 2025 09:48:18 +0300 Subject: [PATCH 6/6] Tomas R -> Roun --- Doc/whatsnew/3.14.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 5767daa60036a9..9fe14c592bd22d 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -272,7 +272,7 @@ Here's an example of using the new module to compress some data: 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., +(Contributed by Emma Harper Smith, Adam Turner, Gregory P. Smith, Tomas Roun, Victor Stinner, and Rogdham in :gh:`132983`) .. seealso:: @@ -953,7 +953,7 @@ ast (Contributed by Irit Katriel in :gh:`123958`.) * The ``repr()`` output for AST nodes now includes more information. - (Contributed by Tomas R in :gh:`116022`.) + (Contributed by Tomas Roun in :gh:`116022`.) * :func:`ast.parse`, when called with an AST as input, now always verifies that the root node type is appropriate.