Skip to main content

bz3 compress and decompress

Project description

✨ python-bz3 ✨

The python binding for bzip3

pypi python implementation wheel license action

install

pip install bzip3

Usage

from bz3 import compress_file, decompress_file, test_file, compress, decompress
import bz3

with open("test_inp.txt", "rb") as inp, open("compressed.bz3", "wb") as out:
    compress_file(inp, out, 1000 * 1000)

with open("compressed.bz3", "rb") as inp:
    test_file(inp, True)    

with open("compressed.bz3", "rb") as inp, open("output.txt", "wb") as out:
    decompress_file(inp, out)

print(decompress(compress(b"12121")))

with bz3.open("test.bz3", "wt", encoding="utf-8") as f:
    f.write("test data")

with bz3.open("test.bz3", "rt", encoding="utf-8") as f:
    print(f.read())
  • use BZ3_USE_CFFI env var to specify a backend

Public functions

from typing import IO, Optional
def crc32(crc: int, buf: bytes) -> int: ...

def compress_file(input: IO, output: IO, block_size: int) -> None: ...
def decompress_file(input: IO, output: IO) -> None: ...
def test_file(input: IO, should_raise: bool = ...) -> bool: ...


class BZ3File:
    def __init__(self, filename, mode: str = ..., block_size: int = ...) -> None: ...
    def close(self) -> None: ...
    @property
    def closed(self): ...
    def fileno(self): ...
    def seekable(self): ...
    def readable(self): ...
    def writable(self): ...
    def peek(self, n: int = ...): ...
    def read(self, size: int = ...): ...
    def read1(self, size: int = ...): ...
    def readinto(self, b): ...
    def readline(self, size: int = ...): ...
    def readlines(self, size: int = ...): ...
    def write(self, data): ...
    def writelines(self, seq): ...
    def seek(self, offset, whence=...): ...
    def tell(self): ...

def open(filename, mode: str = ..., block_size: int = ..., encoding: str = ..., errors: str = ..., newline: str = ...) -> BZ3File: ...
def compress(data: bytes, block_size: int = ...) -> bytes: ...
def decompress(data: bytes) -> bytes: ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bzip3-0.0.1.tar.gz (178.7 kB view hashes)

Uploaded Source

Built Distributions

bzip3-0.0.1-pp38-pypy38_pp73-win_amd64.whl (266.2 kB view hashes)

Uploaded PyPy Windows x86-64

bzip3-0.0.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (279.3 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

bzip3-0.0.1-pp37-pypy37_pp73-win_amd64.whl (266.2 kB view hashes)

Uploaded PyPy Windows x86-64

bzip3-0.0.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (279.4 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

bzip3-0.0.1-cp310-cp310-win_amd64.whl (276.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

bzip3-0.0.1-cp310-cp310-manylinux2014_x86_64.whl (335.6 kB view hashes)

Uploaded CPython 3.10

bzip3-0.0.1-cp310-cp310-macosx_10_15_universal2.whl (438.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)

bzip3-0.0.1-cp39-cp39-win_amd64.whl (276.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

bzip3-0.0.1-cp39-cp39-manylinux2014_x86_64.whl (337.6 kB view hashes)

Uploaded CPython 3.9

bzip3-0.0.1-cp39-cp39-macosx_10_15_x86_64.whl (300.8 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

bzip3-0.0.1-cp38-cp38-win_amd64.whl (277.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

bzip3-0.0.1-cp38-cp38-manylinux2014_x86_64.whl (336.7 kB view hashes)

Uploaded CPython 3.8

bzip3-0.0.1-cp38-cp38-macosx_10_15_x86_64.whl (298.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

bzip3-0.0.1-cp37-cp37m-win_amd64.whl (276.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

bzip3-0.0.1-cp37-cp37m-manylinux2014_x86_64.whl (334.6 kB view hashes)

Uploaded CPython 3.7m

bzip3-0.0.1-cp37-cp37m-macosx_10_15_x86_64.whl (298.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

bzip3-0.0.1-cp36-cp36m-win_amd64.whl (276.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

bzip3-0.0.1-cp36-cp36m-manylinux2014_x86_64.whl (336.1 kB view hashes)

Uploaded CPython 3.6m

bzip3-0.0.1-cp36-cp36m-macosx_10_14_x86_64.whl (301.7 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page