bz3 compress and decompress
Project description
✨ python-bz3 ✨
The python binding for bzip3 with parallel support
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", num_threads=4) as f:
f.write("test data")
with bz3.open("test.bz3", "rt", encoding="utf-8", num_threads=4) as f:
print(f.read())
- use
BZ3_USE_CFFI
env var to specify a backend num_threads
is only available on cython backend which have openmp support
Public functions
from typing import IO, Optional, Union
def compress_file(input: IO, output: IO, block_size: int) -> None: ...
def decompress_file(input: IO, output: IO) -> None: ...
def recover_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 = ..., num_threads: int = ..., ignore_error: bool = False) -> 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 = ..., num_threads: int = 1, ignore_error: bool = False) -> BZ3File: ...
def compress(data: bytes, block_size: int = ..., num_threads: int = 1) -> bytes: ...
def decompress(data: bytes, num_threads: int = 1) -> bytes: ...
def libversion() -> str: ... # Get bzip3 version
def bound(inp: int) -> int: ... # Return the recommended size of the output buffer for the compression functions.
# High-level api
# Compress a block of data into out buffer, zerocopy, both parameters accept objects which implements buffer-protocol.
# out must be writabel, size of out must be at least equal to bound(len(inp))
def compress_into(inp: Union[bytes, bytearray], out: bytearray) -> int: ...
# Decompress a block of data into out buffer, zerocopy
def decompress_into(inp: Union[bytes, bytearray], out: bytearray) -> int: ...
- Note, high-level api won't work with low-level api, see this
Project details
Release history Release notifications | RSS feed
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.1.3rc3.tar.gz
(219.8 kB
view hashes)
Built Distributions
Close
Hashes for bzip3-0.1.3rc3-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1422f2290e808f9e149897a1b6d926c54c8111da32428962da6adc5370e40004 |
|
MD5 | 69820f9649d74b512ec037e0dfe35ba0 |
|
BLAKE2b-256 | 4e3d21ac53bb68b1e0b200c0f35599091c245f442e6f2ca08757e0dd191daf19 |
Close
Hashes for bzip3-0.1.3rc3-pp310-pypy310_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36ae3f24a850c04784be1d81f65c632de6de75617be1fc79ad32b7a0f68e65bf |
|
MD5 | c81b1e9ed79c1d822e7467a95aa94174 |
|
BLAKE2b-256 | b40fe5ee7ac4d4dfefc4d29f1f040a46b3f89f26fdefabdb6de1b4328eccd278 |
Close
Hashes for bzip3-0.1.3rc3-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36b1f368bfcf6dfb79257d8db2fbdae3f85a7e332ff914e6db9c279fec16b00d |
|
MD5 | 50a48717aea8de453746c031cbf4e52c |
|
BLAKE2b-256 | 6d5abde1222cfb765452437adbf9cecd7b512d4b2de3a32b3f877292807c918b |
Close
Hashes for bzip3-0.1.3rc3-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 656dea10bd39af4886d455cc2d6fa5b6336d06c90cbc32c8f9de1cc2f636fc41 |
|
MD5 | e26da96f4260bdb023edf58cae6589ab |
|
BLAKE2b-256 | 5a170f8a1809497910f8e24c6da1df054986b98db43ca4eb25a55aa7546289d1 |
Close
Hashes for bzip3-0.1.3rc3-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 785c3739713f7f4aea0730b35e1cb6938a52972ed22c0a2ad7c9480b88a84e95 |
|
MD5 | 0ca9b76e657f24e7ef3ce88d9bb0da08 |
|
BLAKE2b-256 | bc8243c85c6cf11c616af2d3f737da9d37032e28e9fb3a3a7eca4efd318c527c |
Close
Hashes for bzip3-0.1.3rc3-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45835e4b399deae672bd6bfcd08bd66866492b06b3c5f757a7db5c24261f8184 |
|
MD5 | 91be706e0e71ea89abb07e842825446c |
|
BLAKE2b-256 | 5f0c40ba069255b0a5f1c99ce324a0094b277d0ad1287f3f7f5828c29b81e395 |
Close
Hashes for bzip3-0.1.3rc3-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f742d8e620ba62bce96ef5ccfb3cb8d0a27e065ace6806c0d137254a8f4cec41 |
|
MD5 | 18fafbcbb9676340f9106490ce58436b |
|
BLAKE2b-256 | de9e6db0ed91ff79213d4472752e3c9d815b09f266301f6d5123f52475f79c87 |
Close
Hashes for bzip3-0.1.3rc3-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44aca3677a5e41be335fd61293bbeb6b57ada31e2716d68b7024eea64918b868 |
|
MD5 | b481f96ae423ece84866ee1e48802ecf |
|
BLAKE2b-256 | 987eab1606099b25221330fb1f9568c7382f4b254111c26ed28da3c6b98a2d8d |
Close
Hashes for bzip3-0.1.3rc3-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7ecc64e9d7500789765f688993419a9371b03b741d0112a0519d639942a09ee |
|
MD5 | 3977b776a297f00c240d76d0a3f904c1 |
|
BLAKE2b-256 | 809bf7ce37e445b6579e5f2e5663dae5bf0e5a5780aa34cfffbe9b00b5d1d4c0 |
Close
Hashes for bzip3-0.1.3rc3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a15cd52625a35efd8a193d37ccfe456400eb2c9c915d113e48cae420952d9ffd |
|
MD5 | 258038f4bcc520cc6d7bbb50a7581b47 |
|
BLAKE2b-256 | 94d9b057d568095cac924feb08539410522849ed3d87af8a5c423bdffb471146 |
Close
Hashes for bzip3-0.1.3rc3-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aeea3b89bf370eaf83ca6e6223c22d8058b7838fe16ac96aa8ce26169f72269 |
|
MD5 | 1a313216f1efee40a686088bf401abc8 |
|
BLAKE2b-256 | 51d0fa62248762df939a9c7e6fbf7715c0fbbe4c96983dce61bed40c2af503d6 |
Close
Hashes for bzip3-0.1.3rc3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc3f2506297ab2eee94f9d51a77ea211315088885a254f1a48351712094930fd |
|
MD5 | c8a48235041f78fa531176f13e2d3b90 |
|
BLAKE2b-256 | cdc1e9c5fc32eecac57511b86ff7ba504beddf0ab63f71a49fa64a11bceaa9cd |
Close
Hashes for bzip3-0.1.3rc3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16236abf51f5daf0dcb91caa91ac4afa102d060d145ac45b1c92e665cbaa9767 |
|
MD5 | 76fa49b95b097fe2eff5c47b4e075e69 |
|
BLAKE2b-256 | 916426e3142358910d135ace42418b8a8e2d3a192285c9eec5c2224f8aa24298 |
Close
Hashes for bzip3-0.1.3rc3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d324ca23b71b79837807f4715660886828c7aeb647edd1165decca16f0eee889 |
|
MD5 | 733a608dbf710c6da3ec9c28b229c955 |
|
BLAKE2b-256 | 62ec3f035f66e79b9fda6828ef4dd8eced5f89e1ae1547845f4abe09c1d8681e |
Close
Hashes for bzip3-0.1.3rc3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a28e02fcf68dd36e49c01478cefdf4fb37505bb5558c61577beaefd52946044 |
|
MD5 | 88a38fb45bfb13ee374bba94e077197f |
|
BLAKE2b-256 | 4fa8c3f5514f2de0649705d1f7d79a368c0c666693ce1e9484b84f43e432a6f7 |
Close
Hashes for bzip3-0.1.3rc3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 016b226b54d0a044f88f6e20184e3ca8a85153dac4269eab41615a54ddf1489a |
|
MD5 | deb08376989116d70dbfa4545cc3fb05 |
|
BLAKE2b-256 | 8184f4b84ee700682dcb2b6d875f73fcaff1fb71cf929fe1f4ede8ee0fa62b82 |
Close
Hashes for bzip3-0.1.3rc3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19c14a2206be5c27b948bac057b612b8c29131d2d9bd091eb969c732a438940c |
|
MD5 | d88d532e3fddecb6670e4a2ee5cccf20 |
|
BLAKE2b-256 | f7acc4b271acbf1c1b32143612f792aa38cc50455da1956f40ecab66dd805f80 |