Skip to content

Commit cfe0590

Browse files
Apply suggestions from AA-Turner
Co-authored-by: Adam Turner <[email protected]>
1 parent 63f963f commit cfe0590

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

Doc/library/archiving.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Data Compression and Archiving
55
******************************
66

77
The modules described in this chapter support data compression with the zlib,
8-
gzip, bzip2, zstd, and lzma algorithms, and the creation of ZIP- and tar-format
8+
gzip, bzip2, lzma, and zstd algorithms, and the creation of ZIP- and tar-format
99
archives. See also :ref:`archiving-operations` provided by the :mod:`shutil`
1010
module.
1111

Doc/library/compression.rst

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
The :mod:`!compression` package
2-
=================================
2+
===============================
33

44
.. versionadded:: 3.14
55

6-
.. note::
6+
.. attention::
77

8-
Several modules in :mod:`!compression` re-export modules that currently
9-
exist at the repository top-level. These re-exported modules are the new
10-
canonical import name for the respective top-level module. The existing
11-
modules are not currently deprecated and will not be removed prior to Python
12-
3.19, but users are encouraged to migrate to the new import names when
13-
feasible.
8+
The :mod:`!compression` package is the new location for the data compression
9+
modules in the standard library, listed below. The existing modules are not
10+
deprecated and will not be removed before Python 3.19. The new ``compression.*``
11+
import names are encouraged for use where practicable.
1412

1513
* :mod:`!compression.bz2` -- Re-exports :mod:`bz2`
16-
1714
* :mod:`!compression.gzip` -- Re-exports :mod:`gzip`
18-
1915
* :mod:`!compression.lzma` -- Re-exports :mod:`lzma`
20-
2116
* :mod:`!compression.zlib` -- Re-exports :mod:`zlib`
22-
2317
* :mod:`compression.zstd` -- Wrapper for the Zstandard compression library
2418

25-

Doc/library/compression.zstd.rst

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ Reading and writing compressed files
138138

139139
``'rb'`` for reading and ``'wb'`` for writing.
140140

141-
142141
.. attribute:: name
143142

144-
The zstd file name. Equivalent to the :attr:`~io.FileIO.name`
143+
The name of the Zstandard file. Equivalent to the :attr:`~io.FileIO.name`
145144
attribute of the underlying :term:`file object`.
146145

147146

@@ -542,8 +541,7 @@ Advanced parameter control
542541
compression technique used by zstd, resulting in higher compression
543542
ratios but slower compression.
544543

545-
.. seealso::
546-
:class:`Strategy`
544+
.. seealso:: :class:`Strategy`
547545

548546
.. attribute:: enable_long_distance_matching
549547

@@ -684,11 +682,11 @@ Miscellaneous
684682

685683
.. function:: get_frame_info(frame_buffer)
686684

687-
Retrieve a :class:`FrameInfo`, containing metadata about a Zstandard frame.
688-
Frames contain metadata related to the compressed data they hold.
685+
Retrieve a :class:`FrameInfo` object containing metadata about a Zstandard
686+
frame. Frames contain metadata related to the compressed data they hold.
689687

690688

691-
.. class:: FrameInfo()
689+
.. class:: FrameInfo
692690

693691
Metadata related to a Zstandard frame. There are currently two attributes
694692
containing metadata related to Zstandard frames.
@@ -712,34 +710,38 @@ Miscellaneous
712710

713711
.. attribute:: zstd_version_info
714712

715-
Version number of the runtime zstd library as a tuple of int
713+
Version number of the runtime zstd library as a tuple of integers
716714
(major, minor, release).
717715

718716

719717
Examples
720718
--------
721719

722-
Reading in a compressed file::
720+
Reading in a compressed file:
723721

722+
.. code-block:: python
724723
from compression import zstd
725724
with zstd.open("file.zst") as f:
726725
file_content = f.read()
727726
728-
Creating a compressed file::
727+
Creating a compressed file:
729728

729+
.. code-block:: python
730730
from compression import zstd
731731
data = b"Insert Data Here"
732732
with zstd.open("file.zst", "w") as f:
733733
f.write(data)
734734
735-
Compressing data in memory::
735+
Compressing data in memory:
736736

737+
.. code-block:: python
737738
from compression import zstd
738739
data_in = b"Insert Data Here"
739740
data_out = zstd.compress(data_in)
740741
741-
Incremental compression::
742+
Incremental compression:
742743

744+
.. code-block:: python
743745
from compression import zstd
744746
comp = zstd.ZstdCompressor()
745747
out1 = comp.compress(b"Some data\n")
@@ -749,17 +751,19 @@ Incremental compression::
749751
# Concatenate all the partial results:
750752
result = b"".join([out1, out2, out3, out4])
751753
752-
Writing compressed data to an already-open file::
754+
Writing compressed data to an already-open file:
753755

756+
.. code-block:: python
754757
from compression import zstd
755758
with open("file.zst", "wb") as f:
756759
f.write(b"This data will not be compressed\n")
757760
with zstd.open(f, "w") as zstf:
758761
zstf.write(b"This *will* be compressed\n")
759762
f.write(b"Not compressed\n")
760763
761-
Creating a compressed file using compression parameters::
764+
Creating a compressed file using compression parameters:
762765

766+
.. code-block:: python
763767
from compression import zstd
764768
options = {
765769
zstd.CompressionParameter.checksum_flag: 1

0 commit comments

Comments
 (0)