Skip to content

Allow pre-compressed data to be written into zip files via the zipfile module. #113924

Open

Description

@gpshead

Feature or enhancement

Proposal:

Scenario

You have a larger system generating zip files, often they each contain many of the same files, and you've got a big parallel build setup. All of these would benefit from pre-computing, distributing, and caching the compression of individual members going into the zip file.

Proposal

On zipfile.ZipFile write writestr and open(..., mode="w") methods, add arguments allowing the already compressed data to be provided as-is so that the zipfile modules internal compression step is skipped on those.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. moved this to In Progress in Zipfile issues 📦on Jan 11, 2024
  2. serhiy-storchaka commented on Jan 11, 2024

    @serhiy-storchaka
    Member

    I thought that it would be more useful to add a method that copies data (one or several entries) from a ZIP file to other ZIP file. It can be used to remove from a ZIP archive (there were several requests for this feature). It can be used to merge several ZIP files in one.

  3. gpshead commented on Jan 11, 2024

    @gpshead
    MemberAuthor
  4. sunrisesarsaparilla commented on Oct 11, 2024

    @sunrisesarsaparilla

    I've implemented, used, and tested a version of the feature serhiy-storchaka mentioned. My work is built on top of gpshead's PR draft. I'm soliciting feedback for the API design (and any other feedback is also welcome). I've created a discussion here:

    https://discuss.python.org/t/add-copy-between-zipfiles-without-recompressing-files/67544

  5. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 11, 2024
  6. added 9 commits that reference this issue on Oct 19, 2024
  7. barneygale commented on Oct 19, 2024

    @barneygale
    Contributor

    IMO we could start by adding arguments to ZipFile.open() and ZipExtFile.__init__() only, and then keep an eye on what the community builds with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions