Skip to content

Commit 3c1e0ef

Browse files
Improve compression max_length documentation
1 parent fca7fec commit 3c1e0ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Doc/library/compression.zstd.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,14 @@ Compressing and decompressing data in memory
331331

332332
If *max_length* is non-negative, the method returns at most *max_length*
333333
bytes of decompressed data. If this limit is reached and further
334-
output can be produced, the :attr:`~.needs_input` attribute will
335-
be set to ``False``. In this case, the next call to
334+
output can be produced (or EOF is reached), the :attr:`~.needs_input`
335+
attribute will be set to ``False``. In this case, the next call to
336336
:meth:`~.decompress` may provide *data* as ``b''`` to obtain
337-
more of the output.
337+
more of the output. The full content can thus be read like::
338+
339+
process_output(d.decompress(data, max_length))
340+
while not d.eof and not d.needs_input:
341+
process_output(d.decompress(b"", max_length))
338342

339343
If all of the input data was decompressed and returned (either
340344
because this was less than *max_length* bytes, or because

0 commit comments

Comments
 (0)