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.4.tar.gz
(262.9 kB
view hashes)
Built Distributions
bzip3-0.1.4-cp312-cp312-win_amd64.whl
(394.9 kB
view hashes)
bzip3-0.1.4-cp311-cp311-win_amd64.whl
(393.6 kB
view hashes)
bzip3-0.1.4-cp310-cp310-win_amd64.whl
(393.3 kB
view hashes)
bzip3-0.1.4-cp39-cp39-win_amd64.whl
(394.0 kB
view hashes)
bzip3-0.1.4-cp38-cp38-win_amd64.whl
(394.2 kB
view hashes)
bzip3-0.1.4-cp37-cp37m-win_amd64.whl
(391.1 kB
view hashes)
Close
Hashes for bzip3-0.1.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28cccc46f250dbed26f853d92f7874f9d98e47bd48b2cf4a0368757e36ce91b7 |
|
MD5 | af01c6fc7d191e7b7cdee45af05f70c8 |
|
BLAKE2b-256 | 244e253d2de9b71f6f587a64f9a1af1fa2b05dd47c4e4e53fa15407d7ff234b3 |
Close
Hashes for bzip3-0.1.4-pp310-pypy310_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 579346244024650230f7cd260e913ea6c68f8ca67ea15a0b4c7c08d5b025ee42 |
|
MD5 | 95a984679f0e6aaf7e87f8783122f860 |
|
BLAKE2b-256 | 398a79db99c9398c0379016b414aceb85c840eaa9d00b158adedf076af1052a2 |
Close
Hashes for bzip3-0.1.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 297a9f281bf7c9fcce85b1a429431b5bf8c2fb30dd19e0173699326109865524 |
|
MD5 | 5199551cdfc35daf22fbab6aeb003457 |
|
BLAKE2b-256 | 23d68858c8ffa8f47e6f35c9a180d63f40c5e68df0c6e4287ae01c319f65e06e |
Close
Hashes for bzip3-0.1.4-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76d0a76d9f7093bd2e8f65fd480f93d7cb8427e8248a5e6a04555120f8bb7b0a |
|
MD5 | ceacdec5f3ffd5c40acd86acf6050fdc |
|
BLAKE2b-256 | 6ca3ffdbe9253e4f6b625ee81495b26de6f8515399a946dcab23bb06cdaa1833 |
Close
Hashes for bzip3-0.1.4-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02121835bc17835c3fb2a7103c75d96737694e4cec7608366bdd0cb82f092557 |
|
MD5 | c696284dcdc92f2d8b5a1afa4168f481 |
|
BLAKE2b-256 | e9479ba444381bce4f514cff67e049bc3cd6e6defc2e8f6380fa78116bc2e72e |
Close
Hashes for bzip3-0.1.4-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a391880a4f840e375d751a392fb70c903b151fa91e211bc6798b9cee3eba0c78 |
|
MD5 | efdac172822276094d1ee4950c5b3299 |
|
BLAKE2b-256 | d33c3b0fd9051c5b8e785f4392e54034cfc26bc30541c6c27123fdd52883aff1 |
Close
Hashes for bzip3-0.1.4-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a87bcf2dfa9fb552b1d244d1dda59b438f6bde35af41ff4b57128e9e8fa3ef |
|
MD5 | a1169d35be932adb09ef60e8794a7795 |
|
BLAKE2b-256 | 927d9ad7dff50361bc8d69d95592d40db2ba4b529fca25ea9b619634d158b985 |
Close
Hashes for bzip3-0.1.4-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaac345c735717aa5a1711b55b63255067803ba3a4848d3431d62ae32036737f |
|
MD5 | ac0ebf53b864bb9a0804a18850460179 |
|
BLAKE2b-256 | 2fef80f0e61dcc589c36d73c2fe9ea607cc4e7e3d5a78ba1a0d391de55685a92 |
Close
Hashes for bzip3-0.1.4-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bb60c767e2a752d4599519936f468c74cb4d2496cb5715d4f1701dafe7a0560 |
|
MD5 | 19ece75419d71a657c5b8bd597686889 |
|
BLAKE2b-256 | 0c2283031347c3d4eb29270cb9f358e29ac0008240f4eed5ba4a90b37a1fc991 |
Close
Hashes for bzip3-0.1.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c7067c189b45e34cd03c47cbbfbd424c34c667b13a6d569797ee632215e247a |
|
MD5 | 60bbf92ff66dd8c802489606dc68685a |
|
BLAKE2b-256 | d4a6b0ca17a34491b7314287835ffdb6aaa3b9a31f3725e896d409bda83d75e2 |
Close
Hashes for bzip3-0.1.4-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be3481d4ac33af83da7181a7e6da3243a4707ea5f7da2b818a3ae9c2ffcd5e90 |
|
MD5 | 92aaf7193eff120682c67f82729a811e |
|
BLAKE2b-256 | 11c47e208f592ba52daf6a7a6ae0924580fe831807d2610776707ca1fed5efc1 |
Close
Hashes for bzip3-0.1.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 274ee250ec8df46562ea8971513f7a55418782bd4ae306b15cda280a410c5825 |
|
MD5 | b76a38f452cd1dee5ee712afef6f2f36 |
|
BLAKE2b-256 | b0d9562045f5b6e73dc766a652ce347028bd6208f1549148f1474984063f98b1 |
Close
Hashes for bzip3-0.1.4-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35baaa4f795a48dd8679a8bbdc747d89e3b0d2109dce157c58e09cc031feb273 |
|
MD5 | ebcf8d33f3bfe5fa9a4ccff43ad2b3f4 |
|
BLAKE2b-256 | 6a790cbcadf01d097cf5374da5dafad833e7582f359f04df2a9c3f181ecdef05 |
Close
Hashes for bzip3-0.1.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfca6a0e1be111db8ac051ac3153aa08dea3cd2f605c4ebeb978c3247f928faa |
|
MD5 | 595e70a481c13314de5bf70ec980231b |
|
BLAKE2b-256 | e8968a653eb313da4d5d1fe64e26dcc4bff314007da0d692451358ccbba3495d |
Close
Hashes for bzip3-0.1.4-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e95de15c324bbd5cfeaa8ca8e3dccd20a578b3de7b687faafe40b42fb44ea248 |
|
MD5 | 81ff0c2595340f8dd28681842b5ced6e |
|
BLAKE2b-256 | 74af7219ac225d7430110929751ddcc877496275d56996435c068c4e72194589 |
Close
Hashes for bzip3-0.1.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8da4aba2e0e66d90af50b8ee24837b8bf1764ecccb814794b995654c71c94f9 |
|
MD5 | 2654850ecb71bc27c0745c9981d0871d |
|
BLAKE2b-256 | 10c55ab877510ec5f9ff07e832c94722a9315088c7867e1b1c525ab391c8e3e2 |
Close
Hashes for bzip3-0.1.4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17c60dc96791dc968d46bc83e868fa0e6dc233880bedbe52442ec46a715784e0 |
|
MD5 | c8054a7fa9cba45bb354a3b36b8ce21e |
|
BLAKE2b-256 | 0ed1c6944b4bd5f6932ebe89e05f44d233f7e582bbdadc96e5290c89557c4af0 |
Close
Hashes for bzip3-0.1.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4725be6b8e2a5292d1c21ac5f80d8a9382ea1e81bd3b711691d1b80be79fd4e0 |
|
MD5 | c585184647f2de51ceaf775041dba01b |
|
BLAKE2b-256 | 60952528997694386d6ba504c2ed9908cf0223d362e7db44e9872e2085cb1874 |
Close
Hashes for bzip3-0.1.4-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d17cda94112d5b55f44e45e51a51e2d823e682a6402f4ecdf99d4b92301fd342 |
|
MD5 | 945d2078b0b094865b0d11ae1160969e |
|
BLAKE2b-256 | a9400956b38f840c9d0b1c9afd7d434e119f54f0617e63eb7ecb759a98c31936 |