mirror of
https://github.com/python/cpython
synced 2026-11-06 09:02:40 +03:00
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
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _streams.py | ||