Skip to content

Respect zstd.CompressionParameter.content_size_flag for streaming zstd when possible #140888

@socketpair

Description

@socketpair

Feature or enhancement

Proposal:

from compression import zstd

options = {
   zstd.CompressionParameter.content_size_flag: 1
}

# zstd.open() implementation should call set_pledged_input_size(10)
# should zstd set CompressionParameter.content_size_flag=1 automatically if uncompressed_size passed? I don't know. need to choose API.
with zstd.open("file.zst", "w", options=options, uncompressed_size=10) as f:
    f.write(b"x"*8)  # OK
    f.write(b"aa")  # OK
    f.write(b"z")  # should fail because too many data written. I guess in zstd internal code

# should fail on context exit (because to few data written).  I guess in zstd internal code
with zstd.open("file.zst", "w", options=options, uncompressed_size=10) as f:
    f.write(b"z")  

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirpendingThe issue will be closed if no feedback is providedtype-featureA feature request or enhancement

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions