-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-134938: Add set_pledged_input_size
to ZstdCompressor
#135010
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
gh-134938: Add set_pledged_input_size
to ZstdCompressor
#135010
Conversation
cc @Rogdham |
Also fixup punctuation usage and don't incref Py_None.
@@ -247,6 +247,25 @@ Compressing and decompressing data in memory | |||
The *mode* argument is a :class:`ZstdCompressor` attribute, either | |||
:attr:`~.FLUSH_BLOCK`, or :attr:`~.FLUSH_FRAME`. | |||
|
|||
.. method:: set_pledged_input_size(size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't currently explain why one would want to use the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a bit to describe this, but suggestions welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that mark up should be cleaned up, but there are many occurrences of ~.
in existing documentation, so this can be done in a following PR.
Otherwise LGTM. 👍
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…python into zstd-set-pledged-input-size
@serhiy-storchaka
I'll make a follow up after this is merged to resolve these. |
Thanks @emmatyping for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…onGH-135010) (cherry picked from commit 4b44b34) Co-authored-by: Emma Smith <emma@emmatyping.dev>
GH-135173 is a backport of this pull request to the 3.14 branch. |
This PR adds a new method
set_pledged_input_size()
, which allows users to declare up front how much data will be written to the compressor for a given frame. This combined withCompressionParameter.content_size_flag
allows users to ensure that even for streaming compression scenarios the content size is written into the zstd frame header, which is beneficial for reducing decompression memory usage.📚 Documentation preview 📚: https://cpython-previews--135010.org.readthedocs.build/