Skip to content

gh-132983: Add documentation for compression.zstd #133911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
49d9c30
Add documentation for compression.zstd
emmatyping May 12, 2025
62ef4dc
Add examples
emmatyping May 12, 2025
0b154b1
Fix camelcase name references
emmatyping May 12, 2025
63f963f
CParameter->CompressionParameter
emmatyping May 12, 2025
cfe0590
Apply suggestions from AA-Turner
emmatyping May 12, 2025
5115b4c
Apply suggestions from reviewers
emmatyping May 12, 2025
4ab7fd7
Apply suggestions from reviewers
emmatyping May 12, 2025
5eb5efc
Apply suggestions from reviewers
emmatyping May 14, 2025
987bd27
Don't reference self when referring to items
emmatyping May 14, 2025
615ed7f
Updates to respond to review
emmatyping May 14, 2025
0f7bc05
Remove outdated paragraph
emmatyping May 15, 2025
44173f3
Remove Zstandard dictionary after ZstdDict
emmatyping May 16, 2025
8bd5500
Rewrite introduction to compression package to be more timeless
emmatyping May 18, 2025
24f3761
Remove content_size_flag
emmatyping May 18, 2025
d04ce4f
Merge branch 'zstd-docs' of github.com:emmatyping/cpython into zstd-docs
emmatyping May 18, 2025
e61e9a1
Apply suggestions from Sumana and Stan
emmatyping May 19, 2025
1149832
Remove ref to Meta and clean up mode usage
emmatyping May 20, 2025
71ed7c3
Apply suggestions from vadmium
emmatyping May 20, 2025
2f895dd
Many updates to respond to review
emmatyping May 20, 2025
f25e6e7
Add examples to (De)compressionParameter
emmatyping May 20, 2025
9ff6320
Add reference to zstd manual and blurb on algorithm
emmatyping May 20, 2025
daa9df1
Expand on the connection between level and compression_level
emmatyping May 21, 2025
b3fd3cd
Resolve review suggestions
emmatyping May 21, 2025
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
Apply suggestions from vadmium
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
  • Loading branch information
emmatyping and vadmium authored May 20, 2025
commit 71ed7c3b5efdd6ac77b5ad8e277be9a05324f36e
28 changes: 14 additions & 14 deletions Doc/library/compression.zstd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Reading and writing compressed files
:class:`DecompressionParameter` for detailed information about supported
parameters. The *zstd_dict* argument is a :class:`ZstdDict` instance to be
used during decompression. When opening a file for reading, if the *level*
argument is passed, a :exc:`!TypeError` will be raised.
argument is not None, a :exc:`!TypeError` will be raised.

When opening a file for writing, the *options* argument can be a dictionary
providing advanced decompression parameters; see
Expand Down Expand Up @@ -105,9 +105,9 @@ Reading and writing compressed files
``'w'`` does not truncate the file, and is instead equivalent to ``'a'``.

When opening a file for reading, the *options* argument can be a dictionary
providing advanced decompression parameters, see
providing advanced decompression parameters; see
:class:`DecompressionParameter` for detailed information about supported
parameters. The *zstd_dict* argument is a :class:`!ZstdDict` instance to be
parameters. The *zstd_dict* argument is a :class:`ZstdDict` instance to be
used during decompression. When opening a file for reading, if the *level*
argument is passed a :exc:`!TypeError` will be raised.

Expand Down Expand Up @@ -205,7 +205,7 @@ Compressing and decompressing data in memory
parameters. The valid keys and values for compression parameters are
documented as part of the :class:`CompressionParameter` documentation.

The *zstd_dict* argument is an instance of :class:`ZstdDict`
The *zstd_dict* argument is an optional instance of :class:`ZstdDict`
containing trained data to improve compression efficiency. The
function :func:`train_dict` can be used to generate a Zstandard dictionary.

Expand Down Expand Up @@ -285,7 +285,7 @@ Compressing and decompressing data in memory
The returned data should be concatenated with the output of any previous
calls to :meth:`!decompress`.

If *max_length* is non-negative, returns at most *max_length*
If *max_length* is non-negative, the method returns at most *max_length*
bytes of decompressed data. If this limit is reached and further
output can be produced, the :attr:`~.needs_input` attribute will
be set to ``False``. In this case, the next call to
Expand Down Expand Up @@ -314,7 +314,7 @@ Compressing and decompressing data in memory
.. attribute:: needs_input

``False`` if the :meth:`.decompress` method can provide more
decompressed data before requiring new uncompressed input.
decompressed data before requiring new compressed input.


Zstandard dictionaries
Expand All @@ -330,7 +330,7 @@ Zstandard dictionaries
files), Zstandard dictionaries can improve compression ratios and speed
significantly.

The *samples* argument (an iterable of :class:`bytes`), is the population of
The *samples* argument (an iterable of :class:`bytes` objects), is the population of
samples used to train the Zstandard dictionary.

The *dict_size* argument, an integer, is the maximum size (in bytes) the
Expand Down Expand Up @@ -421,7 +421,7 @@ Zstandard dictionaries

.. attribute:: dict_id

Identifier of the Zstandard dictionary, an int value between zero and .
Identifier of the Zstandard dictionary, a non-negative int value.

Non-zero means the dictionary is ordinary, created by Zstandard
functions and following the Zstandard format.
Expand All @@ -437,7 +437,7 @@ Zstandard dictionaries

.. attribute:: as_digested_dict

Load as a digested dictionary, see below.
Load as a digested dictionary.

.. attribute:: as_undigested_dict

Expand All @@ -450,7 +450,7 @@ Advanced parameter control
.. class:: CompressionParameter()

An :class:`~enum.IntEnum` containing the advanced compression parameter
names that can be used when compressing data.
keys that can be used when compressing data.

The :meth:`~.bounds` method can be used on any attribute to get the valid
values for that parameter.
Expand All @@ -472,7 +472,7 @@ Advanced parameter control

A high-level means of setting other compression parameters that affect
the speed and ratio of compressing data. Setting the level to zero uses
the default :attr:`COMPRESSION_LEVEL_DEFAULT`.
:attr:`COMPRESSION_LEVEL_DEFAULT`.

.. attribute:: window_log

Expand Down Expand Up @@ -509,7 +509,7 @@ Advanced parameter control
decompression speed, but decrease ratio. Note that Zstandard can still
find matches of smaller size, it just tweaks its search algorithm to look
for this size and larger. For all strategies < :attr:`~Strategy.btopt`,
the effective minimum is ``4``, for all strategies
the effective minimum is ``4``; for all strategies
> :attr:`~Strategy.fast`, the effective maximum is ``6``.

.. attribute:: target_length
Expand Down Expand Up @@ -621,13 +621,13 @@ Advanced parameter control
parameter. This method should be called on the attribute you wish to
retrieve the bounds of. For example, to get the valid values for
:attr:`~.window_log_max`, one may check the result of
``CompressionParameter.window_log_max.bounds()``.
``DecompressionParameter.window_log_max.bounds()``.

Both the lower and upper bounds are inclusive.

.. attribute:: window_log_max

The power of two maximum size of the window used during decompression.
The base-two logarithm of the maximum size of the window used during decompression.
This can be useful to limit the amount of memory used when decompressing
data.

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy