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

Improve compression max_length documentation #143805

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

Open
Dreamsorcerer wants to merge 3 commits into python:main
base: main
Choose a base branch
Loading
from Dreamsorcerer:patch-10
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions Doc/library/compression.zstd.rst
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,14 @@ Compressing and decompressing data in memory

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
output can be produced (or EOF is reached), the :attr:`~.needs_input`
attribute will be set to ``False``. In this case, the next call to
:meth:`~.decompress` may provide *data* as ``b''`` to obtain
more of the output.
more of the output. The full content can thus be read like::

process_output(d.decompress(data, max_length))
while not d.eof and not d.needs_input:
process_output(d.decompress(b"", max_length))

If all of the input data was decompressed and returned (either
because this was less than *max_length* bytes, or because
Expand Down
5 changes: 5 additions & 0 deletions Doc/library/zlib.rst
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ Decompression objects support the following methods and attributes:
:attr:`unconsumed_tail`. This bytestring must be passed to a subsequent call to
:meth:`decompress` if decompression is to continue. If *max_length* is zero
then the whole input is decompressed, and :attr:`unconsumed_tail` is empty.
For example, the full content could be read like::

process_output(d.decompress(data, max_length))
while d.unconsumed_tail:
process_output(d.decompress(d.unconsumed_tail, max_length))

.. versionchanged:: 3.6
*max_length* can be used as a keyword argument.
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /