Skip to content

Commit f25e6e7

Browse files
committed
Add examples to (De)compressionParameter
1 parent 2f895dd commit f25e6e7

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

Doc/library/compression.zstd.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ Advanced parameter control
463463
Parameters are optional; any omitted parameter will have it's value selected
464464
automatically.
465465

466+
Example getting the lower and upper bound of :attr:`~.compression_level`::
467+
468+
lower, upper = CompressionParameter.compression_level.bounds()
469+
470+
Example setting the :attr:`~.window_log` to the maximum size::
471+
472+
_lower, upper = CompressionParameter.window_log.bounds()
473+
options = {CompressionParameter.window_log: upper}
474+
compress(b'venezuelan beaver cheese', options=options)
475+
466476
.. method:: bounds()
467477

468478
Return the tuple of int bounds, ``(lower, upper)``, of a compression
@@ -655,13 +665,20 @@ Advanced parameter control
655665
The :meth:`~.bounds` method can be used on any attribute to get the valid
656666
values for that parameter.
657667

668+
Example setting the :attr:`~.window_log_max` to the maximum size::
669+
670+
data = compress(b'Some very long buffer of bytes...')
671+
672+
_lower, upper = DecompressionParameter.window_log_max.bounds()
673+
674+
options = {DecompressionParameter.window_log_max: upper}
675+
decompress(data, options=options)
676+
658677
.. method:: bounds()
659678

660679
Return the tuple of int bounds, ``(lower, upper)``, of a decompression
661680
parameter. This method should be called on the attribute you wish to
662-
retrieve the bounds of. For example, to get the valid values for
663-
:attr:`~.window_log_max`, one may check the result of
664-
``DecompressionParameter.window_log_max.bounds()``.
681+
retrieve the bounds of.
665682

666683
Both the lower and upper bounds are inclusive.
667684

0 commit comments

Comments
 (0)