{"id":16217281,"url":"https://github.com/synodriver/python-bz3","last_synced_at":"2025-03-19T10:30:43.236Z","repository":{"id":41500323,"uuid":"509791598","full_name":"synodriver/python-bz3","owner":"synodriver","description":"python binding for bzip3","archived":false,"fork":false,"pushed_at":"2024-09-21T03:15:04.000Z","size":2406,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T11:26:09.149Z","etag":null,"topics":["bz3","bzip3","cffi","compression","cython"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/synodriver.png","metadata":{"files":{"readme":"README.markdown","changelog":"changename.py","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-02T15:28:35.000Z","updated_at":"2024-09-21T03:15:08.000Z","dependencies_parsed_at":"2023-01-21T09:03:00.639Z","dependency_job_id":"65c050b1-cb2a-4a0c-8ff0-d93436d7784c","html_url":"https://github.com/synodriver/python-bz3","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpython-bz3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpython-bz3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpython-bz3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpython-bz3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synodriver","download_url":"https://codeload.github.com/synodriver/python-bz3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244407728,"owners_count":20447842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bz3","bzip3","cffi","compression","cython"],"created_at":"2024-10-10T11:26:24.498Z","updated_at":"2025-03-19T10:30:43.230Z","avatar_url":"https://github.com/synodriver.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003ci\u003e✨ python-bz3 ✨ \u003c/i\u003e\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003eThe python binding for \u003ca href=\"https://github.com/kspalaiologos/bzip3/tree/master\"\u003ebzip3\u003c/a\u003e with parallel support\u003c/h3\u003e\n\n[![pypi](https://img.shields.io/pypi/v/bzip3.svg)](https://pypi.org/project/bzip3/)\n![python](https://img.shields.io/pypi/pyversions/bzip3)\n![implementation](https://img.shields.io/pypi/implementation/bzip3)\n![wheel](https://img.shields.io/pypi/wheel/bzip3)\n![license](https://img.shields.io/github/license/synodriver/python-bz3.svg)\n![action](https://img.shields.io/github/workflow/status/synodriver/python-bz3/build%20wheel)\n\n### install\n```bash\npip install bzip3\n```\n\n\n### Usage\n```python\nfrom bz3 import compress_file, decompress_file, test_file, compress, decompress\nimport bz3\n\nwith open(\"test_inp.txt\", \"rb\") as inp, open(\"compressed.bz3\", \"wb\") as out:\n    compress_file(inp, out, 1000 * 1000)\n\nwith open(\"compressed.bz3\", \"rb\") as inp:\n    test_file(inp, True)    \n\nwith open(\"compressed.bz3\", \"rb\") as inp, open(\"output.txt\", \"wb\") as out:\n    decompress_file(inp, out)\n\nprint(decompress(compress(b\"12121\")))\n\nwith bz3.open(\"test.bz3\", \"wt\", encoding=\"utf-8\", num_threads=4) as f:\n    f.write(\"test data\")\n\nwith bz3.open(\"test.bz3\", \"rt\", encoding=\"utf-8\", num_threads=4) as f:\n    print(f.read())\n```\n- use ```BZ3_USE_CFFI``` env var to specify a backend\n- ```num_threads``` is only available on cython backend which have openmp support\n\n### Public functions\n```python\nfrom typing import IO, Optional, Union\n\ndef compress_file(input: IO, output: IO, block_size: int) -\u003e None: ...\ndef decompress_file(input: IO, output: IO) -\u003e None: ...\ndef recover_file(input: IO, output: IO) -\u003e None: ...\ndef test_file(input: IO, should_raise: bool = ...) -\u003e bool: ...\n\n\nclass BZ3File:\n    def __init__(self, filename, mode: str = ..., block_size: int = ..., num_threads: int = ..., ignore_error: bool = False) -\u003e None: ...\n    def close(self) -\u003e None: ...\n    @property\n    def closed(self): ...\n    def fileno(self): ...\n    def seekable(self): ...\n    def readable(self): ...\n    def writable(self): ...\n    def peek(self, n: int = ...): ...\n    def read(self, size: int = ...): ...\n    def read1(self, size: int = ...): ...\n    def readinto(self, b): ...\n    def readline(self, size: int = ...): ...\n    def readlines(self, size: int = ...): ...\n    def write(self, data): ...\n    def writelines(self, seq): ...\n    def seek(self, offset, whence=...): ...\n    def tell(self): ...\n\ndef open(filename, mode: str = ..., block_size: int = ..., encoding: str = ..., errors: str = ..., newline: str = ..., num_threads: int = 1, ignore_error: bool = False) -\u003e BZ3File: ...\ndef compress(data: bytes, block_size: int = ..., num_threads: int = 1) -\u003e bytes: ...\ndef decompress(data: bytes, num_threads: int = 1) -\u003e bytes: ...\ndef min_memory_needed(block_size: int) -\u003e int: ...\ndef orig_size_sufficient_for_decode(block: bytes, orig_size: int) -\u003e int: ...\n\ndef libversion() -\u003e str: ... # Get bzip3 version\ndef bound(inp: int) -\u003e int: ... # Return the recommended size of the output buffer for the compression functions.\n\n# High-level api\n# Compress a block of data into out buffer, zerocopy, both parameters accept objects which implements buffer-protocol.\n# out must be writabel, size of out must be at least equal to bound(len(inp))\ndef compress_into(inp: Union[bytes, bytearray], out: bytearray) -\u003e int: ...\n# Decompress a block of data into out buffer, zerocopy\ndef decompress_into(inp: Union[bytes, bytearray], out: bytearray) -\u003e int: ...\n```\n\n- Note, high-level api won't work with low-level api, see [this](https://github.com/kspalaiologos/bzip3/issues/70)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Fpython-bz3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynodriver%2Fpython-bz3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Fpython-bz3/lists"}