Skip to content

gh-113767: Adds a zipfile.register_compressor() API. - #113768

Closed
gpshead wants to merge 2 commits into
python:mainfrom
gpshead:zipfile/compression/plugins
Closed

gpshead wants to merge 2 commits into
python:mainfrom
gpshead:zipfile/compression/plugins

Conversation

@gpshead

@gpshead gpshead commented Jan 6, 2024 •

Copy link
Copy Markdown
Member

This refactors zipfile to add a register_compression() API and uses the API for all of our built-in stdlib based compressors (zlib's deflate, bz2, and lzma).

This allows additional compression methods to be officially supplied by third party libraries without monkeypatching the zipfile module. It is designed to obsolete the gross hacks that things like https://pypi.org/project/zipfile-zstd/ have to do.

Motivation: zstandard support in zipfile, without adding a zstandard implementation to the standard library and without using monkeypatching. But I'm sure others will find it useful as well. Another potential use case is enabling the use of optimized compressors (think parallelized zlib's like pigz) instead of the stdlib default implementations.

TODO items:

  • Overall design review & feature discussions.
  • Code review.
  • Documentation (see the huge zipfile.register_compression docstring for now).
  • NEWS entry & What's New text.

Uses this API for all of our built-in stdlib based compressors.

This allows additional compression methods to be officially supplied by
third party libraries without monkeypatching the zipfile module.

It is designed to obsolete the gross hacks that things like
https://pypi.org/project/zipfile-zstd/ have to do.
@gpshead

gpshead commented Jan 6, 2024

Copy link
Copy Markdown
Member Author

Some further deep diving on the API design and use here is needed. This refactoring and dancing around the decompressor flush method and differing APIs between zlib and bzip2 and lzma was frustratingly informative. #67389 should be considered and perhaps don't require a flush() on the decompressors at all?

@gpshead gpshead removed their assignment Aug 16, 2024
@gpshead

gpshead commented May 21, 2025

Copy link
Copy Markdown
Member Author

chatted with @emmatyping at the pycon US sprint today, she's going to take this on.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 15, 2026
@gpshead

gpshead commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

while the concept is still useful, we've gained compression.zstd in the stdlib so i'm not motivated to push this further.

@gpshead gpshead closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant