compress_sequence
Compresses a sequence of byte strings into a GZIP-encoded stream using a streaming buffer. The function yields compressed data chunks iteratively and can optionally generate a random filename for the GZIP header.
def compress_sequence(
sequence: Iterable[bytes],
max_random_bytes: int | None = None
) - > Generator[bytes, None, None]
Compresses a sequence of byte chunks into a GZIP stream using a generator to yield compressed data incrementally. Use this to stream large datasets through a compression buffer without loading the entire compressed result into memory.
Parameters
| Name | Type | Description |
|---|---|---|
| sequence | Iterable[bytes] | An iterable of byte strings representing the raw data to be compressed. |
| max_random_bytes | `int | None` = None |
Returns
| Type | Description |
|---|---|
Generator[bytes, None, None] | A generator yielding chunks of GZIP-compressed data as they become available from the internal buffer. |