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.3rc2.tar.gz
(219.9 kB
view hashes)
Built Distributions
Close
Hashes for bzip3-0.1.3rc2-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 407158773c7a8e022cb67007e343f5421eff372e9b25cc6353434b46ae93e258 |
|
MD5 | 0faa6276bb66b39667c0016eb1fe2a2a |
|
BLAKE2b-256 | 5d903944564c4cbd0eea4dd798241d62a70d64da7d42f5620ec880228375ec02 |
Close
Hashes for bzip3-0.1.3rc2-pp310-pypy310_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8ad02e45053b675fe578458da4baa62955aa3c298668d64e5ac820796fbcef1 |
|
MD5 | 44c4fb9f3c1d6c80ce0f1979317d9493 |
|
BLAKE2b-256 | f3d0f694c3d83d5c7746dcf3da4cd2ad80b1a8b4e694317f2b68e76671f4090f |
Close
Hashes for bzip3-0.1.3rc2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7be565555ebe1c65f9b80510fa1a076cf8d7462b6abfcb21f28650137a37bf5 |
|
MD5 | feb25183e6327e89d5d9e9d551d4d0e4 |
|
BLAKE2b-256 | e20ee78f6bba9b7112b40aff3d4b4f331072e5cb9b5924ca8c7b1d69107d6f3d |
Close
Hashes for bzip3-0.1.3rc2-pp39-pypy39_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c11fc2d5142c2aa49f072b970992cb7ec5460e1563287a0900325548e65fa55b |
|
MD5 | 0e556c083404afc26dfc86a9f5c6efc6 |
|
BLAKE2b-256 | 19587a1a8e66d02e998ff59bcebb177c7bbbd86e3fa3a344dc36a3f9ff651292 |
Close
Hashes for bzip3-0.1.3rc2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cb7b4e49b0c6ded57bf7c08fef47c816e97505f1b987da0ebb66ad548886c98 |
|
MD5 | 927b5034f0978031fc73cb8aafd6f1fc |
|
BLAKE2b-256 | d08596e93b01261d42980b139807fb8dfd33af36d90f427040e2828b9e4339da |
Close
Hashes for bzip3-0.1.3rc2-pp38-pypy38_pp73-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2f564d7d144e5f5701556a2d518b6d2749a9ae716bcf15cf6368154b68939d5 |
|
MD5 | b11cecadd981f3b6fc1d7fc66d075a14 |
|
BLAKE2b-256 | c78a6fa651b43640a9bf6fd6bf776ee3fca3dec33e9cc43d482c8b41c3f4cc16 |
Close
Hashes for bzip3-0.1.3rc2-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 874cac4ca77dc338301620a03ea699be9f9377da9e92be4c9f9faa533a0aa870 |
|
MD5 | e7182d77fbf4fe2a26e99b1fcfd6bb2c |
|
BLAKE2b-256 | 8e54f0f7a88b874580800a1e57d4de8f26929bfa6e499ee490abaa9caab4af2f |
Close
Hashes for bzip3-0.1.3rc2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b688328408ec8af1f3d68bcc82793417c3c9283cdab226b16611a1697e09b46 |
|
MD5 | 9658fe344b81d202795b364bfb41550a |
|
BLAKE2b-256 | f2cdb216f7e8f9b715753f42cc906ea0a5224b93ff0b963d637d0ceb3f9f270f |
Close
Hashes for bzip3-0.1.3rc2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9443effdf105cf1c83c5f998b98ff494b104cdf8805c0794c414248b4d6b39d9 |
|
MD5 | b8ddeea6d02897eff955aab57c89aebc |
|
BLAKE2b-256 | faf45e4eb48798fe0d0e10ce797ba9135b7d260b9a4eefaf8e898a17af043e55 |
Close
Hashes for bzip3-0.1.3rc2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87280c460f5d436a2743b61831e26c88418b373028e983ea4b25fbb2182907a3 |
|
MD5 | bef2519d914aa140b47c5ffecbe99074 |
|
BLAKE2b-256 | a2ec464432de8ba9d037695435b92fa43d00d67ed7f5580a19ea93c66ccde348 |
Close
Hashes for bzip3-0.1.3rc2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fd699856198457afa6c0fcf821006073ff9782ce353bf22c79cf9ad9b084e87 |
|
MD5 | 0aa4262ee30cdfd3f61c13bc02a257ba |
|
BLAKE2b-256 | 4fcdfb5ccff8dedcd1835b59e4197a60813066aac7f5a1d5c95eba0708de116e |
Close
Hashes for bzip3-0.1.3rc2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 906b650934f36bb714300236974d768a1ea00cf4671894dc56885d20642a118f |
|
MD5 | a9c040d84ff0bf89e931e3cc2d3808d8 |
|
BLAKE2b-256 | 02004e58d70931e0633b3d0446430f87e0aa60c3a13878788d6c2fd3e5624945 |
Close
Hashes for bzip3-0.1.3rc2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15a04cc44b2ce63a04c2ad77afcd167c68259e9701cef23683d3363583f49455 |
|
MD5 | c1e46446354bf72009ce9359fb513e40 |
|
BLAKE2b-256 | 8857138c9a76c69a34ff000311544950de8f670fe78c7f8345e8f9bfbcc91035 |
Close
Hashes for bzip3-0.1.3rc2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1f55dab146a2b2e0fa75aba1e8772b4f204423a72f59b7c84a7f24344c66455 |
|
MD5 | 45bd613df9100b9477dab24baff811ae |
|
BLAKE2b-256 | b1ae8ebcda896f017ea6d525c23fb7f3d64efa2702412040a513f50eb9ed8293 |
Close
Hashes for bzip3-0.1.3rc2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85118b756868be8bb1bb1831eb88c032f60710e488c141ed70551d29f849b412 |
|
MD5 | 3e0d6b5d7f56d813a82c4c1910dd4933 |
|
BLAKE2b-256 | 4f8839cafe9cc582f548d6f33dea25e4dc16ed52fd335b3de79ddbb6e5a1bd78 |
Close
Hashes for bzip3-0.1.3rc2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d3d216916b93dccf049afdc1845aee8d7abf43124e1d66fb49fc68516a6ffce |
|
MD5 | 78b60785e1a0ff9b8bc69d5092e67e69 |
|
BLAKE2b-256 | aaa618fbf25b0dac309d5b8f391c08c464daccbb2bdf7e05daeb18957473c931 |
Close
Hashes for bzip3-0.1.3rc2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa544a148a9432ab394b8bb1347398f25fb519d5607c413d7288f2fae99abb1c |
|
MD5 | f0eeae4853d72ab6009371926150772c |
|
BLAKE2b-256 | 6e35713a7c6b11f36d94290489012db4713ac0d7546419701f07835581d1d113 |