cpython/Lib/compression/_common
Gregory P. Smith c67d3db69e
[3.14] gh-160310: Fix quadratic one-shot decompress() with many members (GH-160311) (#161038)
gzip.decompress(), bz2.decompress(), lzma.decompress() and
compression.zstd.decompress() handed each new decompressor all of the
remaining input and copied the rest back through unused_data, so input
made of many concatenated members took quadratic time.  Each member is
now fed in chunks that start at 1 KiB and double, and the loop steps
back over unused_data by offset.  The first chunk is the whole input,
so single-member data still takes one decompressor call.

bz2, lzma and zstd share the loop through a private helper in
compression._common._streams; gzip keeps its own because it parses the
member header, trailer and padding itself.

ANT-2026-9R8SO5S2

(cherry picked from commit e80962a4bd)
2026-10-31 22:46:32 +00:00
..
__init__.py
_streams.py [3.14] gh-160310: Fix quadratic one-shot decompress() with many members (GH-160311) (#161038) 2026-10-31 22:46:32 +00:00