Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpshead merged 23 commits intopython:mainfromemmatyping:zstd-docs
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
49d9c30
Add documentation for compression.zstd
emmatypingMay 12, 2025
62ef4dc
Add examples
emmatypingMay 12, 2025
0b154b1
Fix camelcase name references
emmatypingMay 12, 2025
63f963f
CParameter->CompressionParameter
emmatypingMay 12, 2025
cfe0590
Apply suggestions from AA-Turner
emmatypingMay 12, 2025
5115b4c
Apply suggestions from reviewers
emmatypingMay 12, 2025
4ab7fd7
Apply suggestions from reviewers
emmatypingMay 12, 2025
5eb5efc
Apply suggestions from reviewers
emmatypingMay 14, 2025
987bd27
Don't reference self when referring to items
emmatypingMay 14, 2025
615ed7f
Updates to respond to review
emmatypingMay 14, 2025
0f7bc05
Remove outdated paragraph
emmatypingMay 15, 2025
44173f3
Remove Zstandard dictionary after ZstdDict
emmatypingMay 16, 2025
8bd5500
Rewrite introduction to compression package to be more timeless
emmatypingMay 18, 2025
24f3761
Remove content_size_flag
emmatypingMay 18, 2025
d04ce4f
Merge branch 'zstd-docs' of github.com:emmatyping/cpython into zstd-docs
emmatypingMay 18, 2025
e61e9a1
Apply suggestions from Sumana and Stan
emmatypingMay 19, 2025
1149832
Remove ref to Meta and clean up mode usage
emmatypingMay 20, 2025
71ed7c3
Apply suggestions from vadmium
emmatypingMay 20, 2025
2f895dd
Many updates to respond to review
emmatypingMay 20, 2025
f25e6e7
Add examples to (De)compressionParameter
emmatypingMay 20, 2025
9ff6320
Add reference to zstd manual and blurb on algorithm
emmatypingMay 20, 2025
daa9df1
Expand on the connection between level and compression_level
emmatypingMay 21, 2025
b3fd3cd
Resolve review suggestions
emmatypingMay 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
PrevPrevious commit
NextNext commit
Apply suggestions from AA-Turner
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
  • Loading branch information
@emmatyping@AA-Turner
emmatyping andAA-Turner authoredMay 12, 2025
commitcfe0590855a5f5c6e36da82baf0703c89d8acf6b
2 changes: 1 addition & 1 deletionDoc/library/archiving.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ Data Compression and Archiving
******************************

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

Expand Down
19 changes: 6 additions & 13 deletionsDoc/library/compression.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
The :mod:`!compression` package
=================================
===============================

.. versionadded:: 3.14

..note::
..attention::

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

* :mod:`!compression.bz2` -- Re-exports :mod:`bz2`

* :mod:`!compression.gzip` -- Re-exports :mod:`gzip`

* :mod:`!compression.lzma` -- Re-exports :mod:`lzma`

* :mod:`!compression.zlib` -- Re-exports :mod:`zlib`

* :mod:`compression.zstd` -- Wrapper for the Zstandard compression library


32 changes: 18 additions & 14 deletionsDoc/library/compression.zstd.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -138,10 +138,9 @@ Reading and writing compressed files

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


.. attribute:: name

Thezstd file name. Equivalent to the :attr:`~io.FileIO.name`
Thename of the Zstandard file. Equivalent to the :attr:`~io.FileIO.name`
attribute of the underlying :term:`file object`.


Expand DownExpand Up@@ -542,8 +541,7 @@ Advanced parameter control
compression technique used by zstd, resulting in higher compression
ratios but slower compression.

.. seealso::
:class:`Strategy`
.. seealso:: :class:`Strategy`

.. attribute:: enable_long_distance_matching

Expand DownExpand Up@@ -684,11 +682,11 @@ Miscellaneous

.. function:: get_frame_info(frame_buffer)

Retrieve a :class:`FrameInfo`,containing metadata about a Zstandard frame.
Frames contain metadata related to the compressed data they hold.
Retrieve a :class:`FrameInfo` objectcontaining metadata about a Zstandard
frame.Frames contain metadata related to the compressed data they hold.


.. class:: FrameInfo()
.. class:: FrameInfo

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

.. attribute:: zstd_version_info

Version number of the runtime zstd library as a tuple ofint
Version number of the runtime zstd library as a tuple ofintegers
(major, minor, release).


Examples
--------

Reading in a compressed file::
Reading in a compressed file:

.. code-block:: python
from compression import zstd
with zstd.open("file.zst") as f:
file_content = f.read()

Creating a compressed file::
Creating a compressed file:

.. code-block:: python
from compression import zstd
data = b"Insert Data Here"
with zstd.open("file.zst", "w") as f:
f.write(data)

Compressing data in memory::
Compressing data in memory:

.. code-block:: python
from compression import zstd
data_in = b"Insert Data Here"
data_out = zstd.compress(data_in)

Incremental compression::
Incremental compression:

.. code-block:: python
from compression import zstd
comp = zstd.ZstdCompressor()
out1 = comp.compress(b"Some data\n")
Expand All@@ -749,17 +751,19 @@ Incremental compression::
# Concatenate all the partial results:
result = b"".join([out1, out2, out3, out4])

Writing compressed data to an already-open file::
Writing compressed data to an already-open file:

.. code-block:: python
from compression import zstd
with open("file.zst", "wb") as f:
f.write(b"This data will not be compressed\n")
with zstd.open(f, "w") as zstf:
zstf.write(b"This *will* be compressed\n")
f.write(b"Not compressed\n")

Creating a compressed file using compression parameters::
Creating a compressed file using compression parameters:

.. code-block:: python
from compression import zstd
options = {
zstd.CompressionParameter.checksum_flag: 1
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp