Skip to content

bz2: return streaming output from BZ2Compressor.compress() #8329

Closed

Description

@doma17

Feature

bz2.BZ2Compressor.compress() does not return output produced while compressing.

import bz2

payload = bytes(range(256)) * 4096
compressor = bz2.BZ2Compressor()

partial = compressor.compress(payload)
final = compressor.flush()

print(len(partial), len(final))

With CPython, partial is non-empty. With RustPython, it is always empty and the output is returned only from flush().

The combined output still decompresses correctly, but this prevents incremental consumption of compressed data.

Python Documentation or reference to CPython source code

https://docs.python.org/3/library/bz2.html#bz2.BZ2Compressor.compress

Activity

  1. doma17 commented on Jul 20, 2026

    @doma17
    ContributorAuthor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions