Repository navigation
Conversation
gzip.decompress(), bz2.decompress(), lzma.decompress() and compression.zstd.decompress() passed all of the remaining input to a new decompressor for every member and copied the rest back via unused_data. Feed each member in chunks of increasing size instead.
gpshead
marked this pull request as ready for review
October 22, 2026 18:57
gpshead
commented
Oct 22, 2026
gpshead
left a comment
Member
Author
There was a problem hiding this comment.
A high level comment I have on this PR... could or should we meaningfully factor out the common shape memoryview loop code used across multiple decompressors?
Member
I think yes, seems reasonable for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The one-shot
decompress()functions ofgzip,bz2,lzmaandcompression.zstdgave each new decompressor all of the remaining input and copied the rest back throughunused_data, so input with many members took quadratic time. They now feed each member in chunks that start at 1 KiB and double, and step back overunused_databy offset; the first chunk is the whole input, so single-member data still takes one decompressor call. Results are unchanged for bytes-like input, butbz2,lzmaandzstdnow slice amemoryviewof the argument, so a non-contiguousmemoryviewraisesTypeErrorwhere it raisedBufferError, and theTypeErrorfor a non-buffer argument has a different message.Fixes #160310
ANT-2026-9R8SO5S2
decompress()ingzip,bz2,lzmaandcompression.zstdis quadratic in the number of members #160310