<h1 align="center"><i>✨ python-bz3 ✨ </i></h1>
<h3 align="center">The python binding for <a href="https://github.com/kspalaiologos/bzip3/tree/master">bzip3</a> with parallel support</h3>
[![pypi](https://img.shields.io/pypi/v/bzip3.svg)](https://pypi.org/project/bzip3/)
![python](https://img.shields.io/pypi/pyversions/bzip3)
![implementation](https://img.shields.io/pypi/implementation/bzip3)
![wheel](https://img.shields.io/pypi/wheel/bzip3)
![license](https://img.shields.io/github/license/synodriver/python-bz3.svg)
![action](https://img.shields.io/github/workflow/status/synodriver/python-bz3/build%20wheel)
### install
```bash
pip install bzip3
```
### Usage
```python
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
```python
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](https://github.com/kspalaiologos/bzip3/issues/70)
Raw data
{
"_id": null,
"home_page": "https://github.com/synodriver/python-bz3",
"name": "bzip3",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "bz3, compress, decompress",
"author": "synodriver",
"author_email": "diguohuangjiajinweijun@gmail.com",
"download_url": null,
"platform": null,
"description": "<h1 align=\"center\"><i>\u2728 python-bz3 \u2728 </i></h1>\r\n\r\n<h3 align=\"center\">The python binding for <a href=\"https://github.com/kspalaiologos/bzip3/tree/master\">bzip3</a> with parallel support</h3>\r\n\r\n[![pypi](https://img.shields.io/pypi/v/bzip3.svg)](https://pypi.org/project/bzip3/)\r\n![python](https://img.shields.io/pypi/pyversions/bzip3)\r\n![implementation](https://img.shields.io/pypi/implementation/bzip3)\r\n![wheel](https://img.shields.io/pypi/wheel/bzip3)\r\n![license](https://img.shields.io/github/license/synodriver/python-bz3.svg)\r\n![action](https://img.shields.io/github/workflow/status/synodriver/python-bz3/build%20wheel)\r\n\r\n### install\r\n```bash\r\npip install bzip3\r\n```\r\n\r\n\r\n### Usage\r\n```python\r\nfrom bz3 import compress_file, decompress_file, test_file, compress, decompress\r\nimport bz3\r\n\r\nwith open(\"test_inp.txt\", \"rb\") as inp, open(\"compressed.bz3\", \"wb\") as out:\r\n compress_file(inp, out, 1000 * 1000)\r\n\r\nwith open(\"compressed.bz3\", \"rb\") as inp:\r\n test_file(inp, True) \r\n\r\nwith open(\"compressed.bz3\", \"rb\") as inp, open(\"output.txt\", \"wb\") as out:\r\n decompress_file(inp, out)\r\n\r\nprint(decompress(compress(b\"12121\")))\r\n\r\nwith bz3.open(\"test.bz3\", \"wt\", encoding=\"utf-8\", num_threads=4) as f:\r\n f.write(\"test data\")\r\n\r\nwith bz3.open(\"test.bz3\", \"rt\", encoding=\"utf-8\", num_threads=4) as f:\r\n print(f.read())\r\n```\r\n- use ```BZ3_USE_CFFI``` env var to specify a backend\r\n- ```num_threads``` is only available on cython backend which have openmp support\r\n\r\n### Public functions\r\n```python\r\nfrom typing import IO, Optional, Union\r\n\r\ndef compress_file(input: IO, output: IO, block_size: int) -> None: ...\r\ndef decompress_file(input: IO, output: IO) -> None: ...\r\ndef recover_file(input: IO, output: IO) -> None: ...\r\ndef test_file(input: IO, should_raise: bool = ...) -> bool: ...\r\n\r\n\r\nclass BZ3File:\r\n def __init__(self, filename, mode: str = ..., block_size: int = ..., num_threads: int = ..., ignore_error: bool = False) -> None: ...\r\n def close(self) -> None: ...\r\n @property\r\n def closed(self): ...\r\n def fileno(self): ...\r\n def seekable(self): ...\r\n def readable(self): ...\r\n def writable(self): ...\r\n def peek(self, n: int = ...): ...\r\n def read(self, size: int = ...): ...\r\n def read1(self, size: int = ...): ...\r\n def readinto(self, b): ...\r\n def readline(self, size: int = ...): ...\r\n def readlines(self, size: int = ...): ...\r\n def write(self, data): ...\r\n def writelines(self, seq): ...\r\n def seek(self, offset, whence=...): ...\r\n def tell(self): ...\r\n\r\ndef open(filename, mode: str = ..., block_size: int = ..., encoding: str = ..., errors: str = ..., newline: str = ..., num_threads: int = 1, ignore_error: bool = False) -> BZ3File: ...\r\ndef compress(data: bytes, block_size: int = ..., num_threads: int = 1) -> bytes: ...\r\ndef decompress(data: bytes, num_threads: int = 1) -> bytes: ...\r\n\r\ndef libversion() -> str: ... # Get bzip3 version\r\ndef bound(inp: int) -> int: ... # Return the recommended size of the output buffer for the compression functions.\r\n\r\n# High-level api\r\n# Compress a block of data into out buffer, zerocopy, both parameters accept objects which implements buffer-protocol.\r\n# out must be writabel, size of out must be at least equal to bound(len(inp))\r\ndef compress_into(inp: Union[bytes, bytearray], out: bytearray) -> int: ...\r\n# Decompress a block of data into out buffer, zerocopy\r\ndef decompress_into(inp: Union[bytes, bytearray], out: bytearray) -> int: ...\r\n```\r\n\r\n- Note, high-level api won't work with low-level api, see [this](https://github.com/kspalaiologos/bzip3/issues/70)\r\n",
"bugtrack_url": null,
"license": "LGPLv3",
"summary": "bz3 compress and decompress",
"version": "0.1.6",
"project_urls": {
"Homepage": "https://github.com/synodriver/python-bz3"
},
"split_keywords": [
"bz3",
" compress",
" decompress"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "94c77306691b94dfe6dddb161b662d77a9333d54d548c66cdb5f45fc341be960",
"md5": "c1bd7e7798cf657fe4f3dcd459c7b754",
"sha256": "dd0d6d3da3d0388e03c800d4e179104de92e12fbaa204e1c465258d0286b119a"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp310-cp310-win32.whl",
"has_sig": false,
"md5_digest": "c1bd7e7798cf657fe4f3dcd459c7b754",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.6",
"size": 364890,
"upload_time": "2024-09-21T07:43:17",
"upload_time_iso_8601": "2024-09-21T07:43:17.876522Z",
"url": "https://files.pythonhosted.org/packages/94/c7/7306691b94dfe6dddb161b662d77a9333d54d548c66cdb5f45fc341be960/bzip3-0.1.6-cp310-cp310-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3523fea53f06adbedad0580e414ea632bbeca9497eec01a9c3e173e2c82e2c7b",
"md5": "a1971b140dd8f24353302711a81444fa",
"sha256": "596709e0200907526240a59f115cd415ac062fcd5e4062c1ac0aff01b3aa7fb5"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "a1971b140dd8f24353302711a81444fa",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.6",
"size": 390249,
"upload_time": "2024-09-21T07:43:19",
"upload_time_iso_8601": "2024-09-21T07:43:19.928059Z",
"url": "https://files.pythonhosted.org/packages/35/23/fea53f06adbedad0580e414ea632bbeca9497eec01a9c3e173e2c82e2c7b/bzip3-0.1.6-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7d2e69863d59a47a9cfb9f541b3dff7fa8404f5163fca88279321de3d73d0ccc",
"md5": "1887dd05b362341db70e1de05c2a9dd1",
"sha256": "9a2a5ef6e4991a2ddefaf58245fee37d36c95c41436482e1c16c4ebfc7e03d1b"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp311-cp311-win32.whl",
"has_sig": false,
"md5_digest": "1887dd05b362341db70e1de05c2a9dd1",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.6",
"size": 364763,
"upload_time": "2024-09-21T07:43:21",
"upload_time_iso_8601": "2024-09-21T07:43:21.408389Z",
"url": "https://files.pythonhosted.org/packages/7d/2e/69863d59a47a9cfb9f541b3dff7fa8404f5163fca88279321de3d73d0ccc/bzip3-0.1.6-cp311-cp311-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bf1fe30546bf63e94351a9a4d4ffef50fbb067dd8051edd9e0d5717461bb55af",
"md5": "51ed8488eac6ce275b1a68b7473cf873",
"sha256": "4c7a65ef02f202a7383e031c45e923adc958a4764d80c49f24e54ba335fdfd62"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "51ed8488eac6ce275b1a68b7473cf873",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.6",
"size": 390282,
"upload_time": "2024-09-21T07:43:22",
"upload_time_iso_8601": "2024-09-21T07:43:22.687301Z",
"url": "https://files.pythonhosted.org/packages/bf/1f/e30546bf63e94351a9a4d4ffef50fbb067dd8051edd9e0d5717461bb55af/bzip3-0.1.6-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "89f4fb9ed403092e0df7995bc8a8a21023e5bed7475bd98600fb868dd2be9863",
"md5": "b0718d15092dcee18a335974366bc6f1",
"sha256": "1a57b9d0212c0cedda34e6d5a70268a2db33698607de0f18d6f9c12dae690a85"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp312-cp312-win32.whl",
"has_sig": false,
"md5_digest": "b0718d15092dcee18a335974366bc6f1",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.6",
"size": 367525,
"upload_time": "2024-09-21T07:43:24",
"upload_time_iso_8601": "2024-09-21T07:43:24.266997Z",
"url": "https://files.pythonhosted.org/packages/89/f4/fb9ed403092e0df7995bc8a8a21023e5bed7475bd98600fb868dd2be9863/bzip3-0.1.6-cp312-cp312-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1f9bb91ba32171d5e7abd5a1a1b1f588db86440ad6cfce9c8336fbdfa2df8542",
"md5": "6081664d333a8e7d19dcf5a3f6e5b887",
"sha256": "907aed9a8e2781364fc2093b9610111c1aad4c2e4d067b9112910fe010427948"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "6081664d333a8e7d19dcf5a3f6e5b887",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.6",
"size": 392399,
"upload_time": "2024-09-21T07:43:25",
"upload_time_iso_8601": "2024-09-21T07:43:25.568679Z",
"url": "https://files.pythonhosted.org/packages/1f/9b/b91ba32171d5e7abd5a1a1b1f588db86440ad6cfce9c8336fbdfa2df8542/bzip3-0.1.6-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "428d331bdf94af046ace13c156a8f6d887ed694596821e008e594913b0cd2d98",
"md5": "401e9cb333f329784b5ef9be314b8f83",
"sha256": "8ad89767614582a6888a476630a2777c7f9c99749db94841cdb930dd912d21e1"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp38-cp38-win32.whl",
"has_sig": false,
"md5_digest": "401e9cb333f329784b5ef9be314b8f83",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.6",
"size": 365578,
"upload_time": "2024-09-21T07:43:27",
"upload_time_iso_8601": "2024-09-21T07:43:27.087249Z",
"url": "https://files.pythonhosted.org/packages/42/8d/331bdf94af046ace13c156a8f6d887ed694596821e008e594913b0cd2d98/bzip3-0.1.6-cp38-cp38-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "890bb7fed4032095584f3cf3bc1646b04391bc93da880d3eb5fef8837ebfd20b",
"md5": "108730ef03b0a04b31666457123817ca",
"sha256": "eac258e50c510ba8dd57b05908e6c79d52568d356978501cb507036be670b0c7"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp38-cp38-win_amd64.whl",
"has_sig": false,
"md5_digest": "108730ef03b0a04b31666457123817ca",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.6",
"size": 391160,
"upload_time": "2024-09-21T07:43:28",
"upload_time_iso_8601": "2024-09-21T07:43:28.373962Z",
"url": "https://files.pythonhosted.org/packages/89/0b/b7fed4032095584f3cf3bc1646b04391bc93da880d3eb5fef8837ebfd20b/bzip3-0.1.6-cp38-cp38-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5f10bf276c4a0fbb6518fad128e434f2c2a8f3222924ef236820014965b5e33e",
"md5": "a9e63eec58716d7167eacb92fbd7aa1e",
"sha256": "670e7d35ff2bc69df6223a36782644be79b6e53c66297d575455e8b95174724a"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp39-cp39-win32.whl",
"has_sig": false,
"md5_digest": "a9e63eec58716d7167eacb92fbd7aa1e",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.6",
"size": 365516,
"upload_time": "2024-09-21T07:43:29",
"upload_time_iso_8601": "2024-09-21T07:43:29.412617Z",
"url": "https://files.pythonhosted.org/packages/5f/10/bf276c4a0fbb6518fad128e434f2c2a8f3222924ef236820014965b5e33e/bzip3-0.1.6-cp39-cp39-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f4bd3d77abff4299eb026fc5f0a15eb4753680922ea8a2ee26f28b78d1515e12",
"md5": "731bf5284068d9bf6f02e83a986c166a",
"sha256": "bb918a33d0998d6482506551fb3103d6071980842c15f898b6e2b2ff6a6a81f2"
},
"downloads": -1,
"filename": "bzip3-0.1.6-cp39-cp39-win_amd64.whl",
"has_sig": false,
"md5_digest": "731bf5284068d9bf6f02e83a986c166a",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.6",
"size": 391028,
"upload_time": "2024-09-21T07:43:30",
"upload_time_iso_8601": "2024-09-21T07:43:30.545813Z",
"url": "https://files.pythonhosted.org/packages/f4/bd/3d77abff4299eb026fc5f0a15eb4753680922ea8a2ee26f28b78d1515e12/bzip3-0.1.6-cp39-cp39-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "800ddb8563240e6d3bc39e0615d68173e47a1d5d9da1bd0c318dcfd9f9d6f71f",
"md5": "f7112621624a82ffd33be7d3c86dbf00",
"sha256": "29ef97afbad4e7e6688c97d859fc6b62273b70df91e24ac0a38b1bbe51ea65cb"
},
"downloads": -1,
"filename": "bzip3-0.1.6-pp310-pypy310_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "f7112621624a82ffd33be7d3c86dbf00",
"packagetype": "bdist_wheel",
"python_version": "pp310",
"requires_python": ">=3.6",
"size": 380603,
"upload_time": "2024-09-21T07:43:32",
"upload_time_iso_8601": "2024-09-21T07:43:32.230696Z",
"url": "https://files.pythonhosted.org/packages/80/0d/db8563240e6d3bc39e0615d68173e47a1d5d9da1bd0c318dcfd9f9d6f71f/bzip3-0.1.6-pp310-pypy310_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2fd615fc19bbe13c997cc3b73f7ac8d4d6a604c7e2b8a97f2372913604ed8f8",
"md5": "84866cdf9daae191cf6e57cce110e2a4",
"sha256": "e8d776d63d4579ed9d7ef4db6e530f26ecb39c9208c64ab0b9f804e18e640bee"
},
"downloads": -1,
"filename": "bzip3-0.1.6-pp38-pypy38_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "84866cdf9daae191cf6e57cce110e2a4",
"packagetype": "bdist_wheel",
"python_version": "pp38",
"requires_python": ">=3.6",
"size": 379978,
"upload_time": "2024-09-21T07:43:33",
"upload_time_iso_8601": "2024-09-21T07:43:33.750527Z",
"url": "https://files.pythonhosted.org/packages/e2/fd/615fc19bbe13c997cc3b73f7ac8d4d6a604c7e2b8a97f2372913604ed8f8/bzip3-0.1.6-pp38-pypy38_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8d1566c0c919dcbfe989d3ffd58068a9683c108c36b7d54d1f0c212d86998f59",
"md5": "a25d24ed4938bb6bdada1b6e78c052b5",
"sha256": "505af48a54a6aaed6d6a58ca159e33fcdf4e304d0e306c01a49b391be27de3aa"
},
"downloads": -1,
"filename": "bzip3-0.1.6-pp39-pypy39_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "a25d24ed4938bb6bdada1b6e78c052b5",
"packagetype": "bdist_wheel",
"python_version": "pp39",
"requires_python": ">=3.6",
"size": 380442,
"upload_time": "2024-09-21T07:43:35",
"upload_time_iso_8601": "2024-09-21T07:43:35.179271Z",
"url": "https://files.pythonhosted.org/packages/8d/15/66c0c919dcbfe989d3ffd58068a9683c108c36b7d54d1f0c212d86998f59/bzip3-0.1.6-pp39-pypy39_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-21 07:43:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "synodriver",
"github_project": "python-bz3",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "Cython",
"specs": [
[
">=",
"3.0.10"
]
]
},
{
"name": "cffi",
"specs": [
[
">=",
"1.0.0"
]
]
}
],
"lcname": "bzip3"
}