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.2.tar.gz
(215.1 kB
view hashes)
Built Distributions
bzip3-0.1.2-cp311-cp311-win_amd64.whl
(325.9 kB
view hashes)
bzip3-0.1.2-cp310-cp310-win_amd64.whl
(327.4 kB
view hashes)
bzip3-0.1.2-cp39-cp39-win_amd64.whl
(328.1 kB
view hashes)
bzip3-0.1.2-cp38-cp38-win_amd64.whl
(328.9 kB
view hashes)
bzip3-0.1.2-cp37-cp37m-win_amd64.whl
(326.7 kB
view hashes)
Close
Hashes for bzip3-0.1.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f2d6b9e24243d818724506c3f3dd669bddb3228643e58788d1d651f07687a6c |
|
MD5 | 890e31d0a280c6c07b90834df0cfd49f |
|
BLAKE2b-256 | 31d2b27da6d64e68da82f54c572f9ddf174191e9afe5a04425a9145f89721915 |
Close
Hashes for bzip3-0.1.2-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c59ecae430e3586605dc66525113cc359109bb623be89c89baced4656e13a0a |
|
MD5 | 69bb71ae42d8ee209b6bf51e35952040 |
|
BLAKE2b-256 | b64305c6c3541638492b5aafb8e9de250e8d6e0fa3cfcdc92d9e6bad83c7bf16 |
Close
Hashes for bzip3-0.1.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b96de98fc3de05c8f7e599591f3a87bc5e9f0a92afdf9d0cc26cee7d02d10ad6 |
|
MD5 | ea82abdb2bf6e455c0137bc11db1bd96 |
|
BLAKE2b-256 | fafb8bbc20a69da60d972b5c954baef79a8404be3d606e93bc557ebc316a4d72 |
Close
Hashes for bzip3-0.1.2-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d62bfdb114b532dda08f5d7517ecaf8f33ac2ab50a3be77426499a438ce94608 |
|
MD5 | 5baffeadc3b97a417962ad513f2bf63a |
|
BLAKE2b-256 | 61e3b761afd95a6e6cb06dc786eb58587deb6b03d84bd315af79565ddb804ccc |
Close
Hashes for bzip3-0.1.2-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 274a9bd22d3d87f89a41a3d338e326f94d7983fd845701be2ee148e409182527 |
|
MD5 | 6bb8eb70cc824e5cb5058bc606ea3d35 |
|
BLAKE2b-256 | 611765cbd76ac385dd38bee96e888fec7ef922f4792c6e298c07b04a89fc71dd |
Close
Hashes for bzip3-0.1.2-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a6086d714c699ef20ee8c42ccf618582e1e592acadfec0b2ce2591e1134e415 |
|
MD5 | 91b1b4e4b96951ac11962d0b033cd56d |
|
BLAKE2b-256 | 7b3b80cea3793bf1a32f0949192e5d74ee40ec333b19b052b6495529cacfd7d8 |
Close
Hashes for bzip3-0.1.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3cc6e3f9987349b6fcb628177219652fa8ce40c7e474dd6b4bc50e2b1e8597f |
|
MD5 | 3133f0fa98ebc8b2e3d3cab13f8208df |
|
BLAKE2b-256 | 9f16191e36fd447fe146b048a912dbff7c829dd2ef6c5fd7791fe0959fea1ecd |
Close
Hashes for bzip3-0.1.2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ef06592c22939b79c8aa266d43627fb1c3c402ac142a07dcd1ed37bc2903fa3 |
|
MD5 | 8e3cac3d4fb70fd604c483adec0554f1 |
|
BLAKE2b-256 | d5ee50405de3a9fa251ed70788bd6e1b2931a2a23452bcff269c892e095b5764 |
Close
Hashes for bzip3-0.1.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef233887d61fa79bc45850a8d8b119b91bb096d5ccff9bb8606a34f76c7c2285 |
|
MD5 | 98b54d9a24590ae498ebea799ad996bd |
|
BLAKE2b-256 | b7fc48d48f3c7c6b6252e34808446383611e8ca161082af5a44961812d26bb1f |
Close
Hashes for bzip3-0.1.2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fecbf21a65b48878af755b8ce5213179dd0f271252c444c368d9624103b2a0ea |
|
MD5 | 877607ead24a2e592ebc3c3c87a4327d |
|
BLAKE2b-256 | 1c3923943f325af306b27ec9ed98ffe08efc53d9969638e7d88fc3efcb513a5f |
Close
Hashes for bzip3-0.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e951967a2d17d647e2172603b6c71b937a6a0d1dba0eb27744f01ad1016b62 |
|
MD5 | e0d4ab98afd408c0022a6cb516ba7266 |
|
BLAKE2b-256 | 60605c842efa98300cd3797a7c7b812f4e3af241a285bd39c5a483c84f858e79 |
Close
Hashes for bzip3-0.1.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb5be3e53aff71f641501cdce997d022eee5ed7964879ae6d81133c829f65a12 |
|
MD5 | 821c638b564c75fe984e617ad6c37b59 |
|
BLAKE2b-256 | db9eca66a1e10251c30c708ca2c661cf840a71e49bb9e280f565e21585a3b2dc |
Close
Hashes for bzip3-0.1.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ccec48b7fcf169f4f1d201b1f87503818163bf0fd03cc984c75107dc2680602 |
|
MD5 | 9c8b426a08db9921ba8f08c2ab63008b |
|
BLAKE2b-256 | 383cb6b946c11ac57ea3f44c4d3879260fda1c196a20336ed14008084e892e21 |
Close
Hashes for bzip3-0.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55756838b4c5bea94d6f81a16d06720e024937e95a95f65b6306f1dbe87b63c2 |
|
MD5 | c45d0d1631f63585637d139cc18296bb |
|
BLAKE2b-256 | eee0d68b5f15837c6f279888330d6b7ad78342b9dda61afec4631dde2510ea16 |
Close
Hashes for bzip3-0.1.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d978225c87ca3b42742b32c364cd97b4f4d0fdc1eb4130cdc547e53ce99a2ac3 |
|
MD5 | 2475a05c5ba728940d5de71115d2b8a0 |
|
BLAKE2b-256 | 0d7a95db051b0f28dde5cf328df375a6c428e989874812aa0d53fcfaa5ac8ebe |
Close
Hashes for bzip3-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba3f9288c427ff9e30f8eda4c159b10d31b8f6d008504c0b000aa4adf09b798e |
|
MD5 | 66fe19978185b2159493e247ab8b5895 |
|
BLAKE2b-256 | cfc92e05f1dbcd2c39aefca10bbd0df19aaa0cbca3f94e61c91af84fa6c0857c |
Close
Hashes for bzip3-0.1.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6f59815acf9e360252c9cad3807ff2f5d5575781d3e55b9b1f1b83ba8999f48 |
|
MD5 | c2030695bf770514b7e78b8157d0a276 |
|
BLAKE2b-256 | d3f78650436c8967d8d0a46393146303360ae601243d415a9293d47b13de93a6 |