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.3rc1.tar.gz
(219.9 kB
view hashes)
Built Distributions
Close
Hashes for bzip3-0.1.3rc1-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda3ac59a5b02246384c2bd3dbe8bf7c228ee4cac8cd8ed59c29b0364d48e105 |
|
MD5 | e8887443c05e19b417700baf78af64a3 |
|
BLAKE2b-256 | d6bb2f436a7c540f2074740bd1951fc5058c3a09748d9e329ae4806ef2aecfd2 |
Close
Hashes for bzip3-0.1.3rc1-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f0b00d0d9c32618516e75a388094f960380478c0ec4b264a4fa62c2753056ec |
|
MD5 | 708f248b7a1a3b5a10ff649180935a8a |
|
BLAKE2b-256 | 16b32870c125dde9515485666817314d70c166984cc5ae9ea6b2b0e27b56392e |
Close
Hashes for bzip3-0.1.3rc1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a64b17f4a8930fad66417b108946d3d1201d0a5d4001d39f8aea978e8670a822 |
|
MD5 | 27f7f7c3712c516ec4c5fbf73f6d6028 |
|
BLAKE2b-256 | d674a4374fb07b4b7fe6ac8b5a76b85fa3a06298f3f63d02f7adbc277e7649cf |
Close
Hashes for bzip3-0.1.3rc1-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02d0551f53ca92f4de1061457e448a86c2958284e6809da2a72395c48bebbd14 |
|
MD5 | 850494e277267dfb976bcbb1db5b1106 |
|
BLAKE2b-256 | 21dbf6d69920c353699be801db566674bb1744866d3254ee4641ac25fdd944bd |
Close
Hashes for bzip3-0.1.3rc1-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6682a12eba9a2e82e57632a51b68ce62dc20cdc3b16d3cdfdf3290ac3bab4f56 |
|
MD5 | 76d6c1e03196e19c61ab58bcbfaa7349 |
|
BLAKE2b-256 | b6c6ea6ed9bff38e5bb66e71169b83afd3f627b5b715ca09ac85bf96e2fe67ed |
Close
Hashes for bzip3-0.1.3rc1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2acf0423c5d5ca59f21e0b9402e412fadceb44900882a26084d12812be7e095 |
|
MD5 | 146dc47194544e1e80a125fe44d19c6f |
|
BLAKE2b-256 | cc9ca30c5959568eb0814c80120b44bb2da74750fb8202c35056d7381dcc0001 |
Close
Hashes for bzip3-0.1.3rc1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1d942e1952c1bfa73613fd39f873cbb8ee5010182c4af419ec80c222b558cfa |
|
MD5 | 9494e15eb5cb5b58875a5eb92cd49282 |
|
BLAKE2b-256 | dec70a94bf04e2a56be7cdbb50260d4fbbe16bcfdd695587c4751b1763fbf8ed |
Close
Hashes for bzip3-0.1.3rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cb17ba790b6bd4c7dc30cbf7f2a5094be7e15bc69ff2013c52ecbf5d3025bb3 |
|
MD5 | 5201e6aefed2ef4ee281cc88a7ca0900 |
|
BLAKE2b-256 | d51b838947f71b58cdab24ea25f3dfd59f6757caac6dec633e95d7b36915d700 |
Close
Hashes for bzip3-0.1.3rc1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 474f40269034f73331b5d92a04865d66488d855702305ab98c3b562d4ef0c0bd |
|
MD5 | 66b70f84e8054b7c3eb66bb72eed9953 |
|
BLAKE2b-256 | 4b2f00349936966afda526c58b4464ddc5e104c0e91344e2d2f544a2cc1dc8b8 |
Close
Hashes for bzip3-0.1.3rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 481695bb6ca8df3d60698888cd4bd11580304c965e85ec0b1701c4869e171116 |
|
MD5 | 032d3c2f68187017af6d048aa1af4041 |
|
BLAKE2b-256 | e6c317762c86e2ab771a659b2b2c23192156324a25ff523334f4a040a87c973a |
Close
Hashes for bzip3-0.1.3rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a55c02ce4c9aeb868d63757416a8322300ddaad038e9482d6c02e832bffffda |
|
MD5 | 4928538c3d50ee4e9c41a1846a1d448f |
|
BLAKE2b-256 | 3f9ed83e0d0ade5a52fee2ca706116047452a34c6a20983926caadf77c2a8a0e |
Close
Hashes for bzip3-0.1.3rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 890b4c858fb1d89a49f31f8f4ac5e32fa67bd829eb3eee7112e271299e80d98b |
|
MD5 | b700067fc4acd88f0f6b606a5ecbdc49 |
|
BLAKE2b-256 | 327fbe17073b674c37b45a9072f2769cdd71a3cf974139b1f6059ca35d5fafa4 |
Close
Hashes for bzip3-0.1.3rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a838451bc2226cc5d779aa8626487816eab25b800327bee2f7d6d317b4fb695 |
|
MD5 | 61430c6c2cf5ea94084176db00a10c6a |
|
BLAKE2b-256 | 33f2c0f64ba84767c96982cc22357a645a741935b457254dd024dae946526a78 |
Close
Hashes for bzip3-0.1.3rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4952facb9741bdf5835d437ddf6b592045c13f2336898d4396d532d458ecae4f |
|
MD5 | b1ccadbd93b91283bce1d959d0cbeb00 |
|
BLAKE2b-256 | 5c7f6097dbc7268efbed941ce161ebf2e326ea692fa0468fed8032bd5f2d2323 |
Close
Hashes for bzip3-0.1.3rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 285922b2757e7953bfcbb564642e211cfadcf951e2a07be2ff2ce9936e8e2dbe |
|
MD5 | 2a9404f170d9dc230424ed7300eb3efa |
|
BLAKE2b-256 | 1da75115ab3f3032aae832762edeef9c943d034ea8005aa0cf5e7d6c2f32659a |