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
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 = ..., num_threads: 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 = ..., num_threads: int = 1) -> 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.2rc1.tar.gz
(255.7 kB
view hashes)
Built Distributions
Close
Hashes for bzip3-0.1.2rc1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ca45ef47fcb4efb9b927b14fe4d4cde89afcd4245cbe5fa4b437f5da577e3d3 |
|
MD5 | 8c44008b4b3508890fc5b9170061c6b8 |
|
BLAKE2b-256 | 0ad11c404f5fb3733a3350e5291530dc9e3ce77a25fb63ac4693f74628ac410e |
Close
Hashes for bzip3-0.1.2rc1-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee0ad4bcce0ea988e6387ddd79625ff95d4c4b4681c0f46c2abf5d826a967747 |
|
MD5 | 7a1109cdbcf23f1acaee7e23f343bfdf |
|
BLAKE2b-256 | c7312aa688a3cf9668593962636bf8849484e346c5ad6db74177445baacfccba |
Close
Hashes for bzip3-0.1.2rc1-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02b3c88056b20f635678696881a3161dc8dce8322853e2a51be4207dc0c9b592 |
|
MD5 | fd02bb6ea507804c6e876bbd4555132e |
|
BLAKE2b-256 | 5e6748708e0a28565adbf24599690743861624545308a0988266458c782e058f |
Close
Hashes for bzip3-0.1.2rc1-pp37-pypy37_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 836143bbf9eededb18989a41437996353a9bcab2b504ebdf195616fbd5de3f1c |
|
MD5 | dd63a462234bfe9687dd5d6bc5c2bb03 |
|
BLAKE2b-256 | 2453286ab6ae339fe4fe2a045a90f1edb485e9bee737ef860591d2fe41612f4c |
Close
Hashes for bzip3-0.1.2rc1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84632de0496b200fc39198b963d30ec58faa9cf4d575dbf98e44d98e9a458d1b |
|
MD5 | 457b8dbb701d0718181f9497c75831be |
|
BLAKE2b-256 | 4c482a869b8ad6154008f2b98a32827985921870de255612be38a0c4bbdc268e |
Close
Hashes for bzip3-0.1.2rc1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89b09054a583b5005077e8c5c73299defa68c204007ab2eae348821d7eb5050c |
|
MD5 | 3a6468d9823ab68d33fae195a2326f57 |
|
BLAKE2b-256 | 30f99f56b023658790afbfe9de48ec5fb08c933bce7df576b3a2667870e8982f |
Close
Hashes for bzip3-0.1.2rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d089cf1a30573238fee8b5c7b68458bca64f725b5fcab02307ed4a0dabce31fb |
|
MD5 | c7a554a069d6dcd0fb54493702820389 |
|
BLAKE2b-256 | 58ad260b2fc3de974262be30c912d00a0b438c1486d1d85bad08d69db1cc18a6 |
Close
Hashes for bzip3-0.1.2rc1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee0b37324fae254d45eaee8fde62d7cd60d6441831050c1db561194598664c4a |
|
MD5 | 75be3f3ed5be98dba86fd7e191fa02bb |
|
BLAKE2b-256 | 286afffb4a5cbb125b6d9afc12dce81f91cd10a7f0ba3daa51e6d9ee0da1c552 |
Close
Hashes for bzip3-0.1.2rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6baa1abb8061eee6accaee4530d2bff7e40cfcf83e17e50ab567508c49534d12 |
|
MD5 | 997b9a5eb49cda435dfc11d33ef223fe |
|
BLAKE2b-256 | 23135cfe9ec2477a5f841021cc39b9fb26173d1eb463ae27bea2b7ead94a0b2b |
Close
Hashes for bzip3-0.1.2rc1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d5bc47250a27d2718159c3fb761c199b0f7c31c39d466693fde8d62bc87f16 |
|
MD5 | 51eddc78da97480cb5b5d5d6bd05b04a |
|
BLAKE2b-256 | 198a0dbf35bf3a1f27644bdc044291f3a0bf5844ba91f6fb86115eca05840d5f |
Close
Hashes for bzip3-0.1.2rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0b30fa655aa5ed832be8975eed6c120e0cc374a7ce5ebef389e41294400d289 |
|
MD5 | 501d7a4764eb1831a9c2d029cf4ee4a9 |
|
BLAKE2b-256 | 73401a3e95a5a30bfaa4aa990ec87a5b2a5418c377438631a51d2bce635a1a52 |
Close
Hashes for bzip3-0.1.2rc1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d9c1649b96eb488297beb65671951c627383b545b4b7b8be4feae5eb28d0540 |
|
MD5 | 5db2c7fb2ae3c7c9fe4b4611f5baae9f |
|
BLAKE2b-256 | 0b707ea7fa797a75e18f246916e47f638959b42f6d6f1fed76d83f443005b1d4 |
Close
Hashes for bzip3-0.1.2rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c03ab3c77144784d8dbfcd262d179275955cbf1942d613e8a2e9f0544c8849c6 |
|
MD5 | ffd59697ad8d7d0c4858456649bd63c3 |
|
BLAKE2b-256 | aea834ca83d44bfa627d818b8f31266d06072296edea35fccf2776a50c2e112a |
Close
Hashes for bzip3-0.1.2rc1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bcc4ebb81450592605b9eda549f4c5035310f7b88ad08abc0706c2e08516692 |
|
MD5 | 543c46e2d7e7e7bd287a567ae3fa2a3d |
|
BLAKE2b-256 | 9043fbf7af1946c549981f40ee9192fd82a5bf217be1e4f4005ade5e0b9fcfd0 |