{"id":16217273,"url":"https://github.com/synodriver/pydensity","last_synced_at":"2025-03-19T10:30:42.551Z","repository":{"id":45704348,"uuid":"513430604","full_name":"synodriver/pydensity","owner":"synodriver","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-13T14:46:07.000Z","size":415,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T06:11:23.893Z","etag":null,"topics":["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-13T07:56:02.000Z","updated_at":"2022-11-02T22:15:14.000Z","dependencies_parsed_at":"2024-10-27T20:30:49.753Z","dependency_job_id":"262034f6-d176-49c4-ba83-a7ea8cb6ad22","html_url":"https://github.com/synodriver/pydensity","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"9aaaf8722dac0bc82a9df4bc816353c0ceb65816"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpydensity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpydensity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpydensity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Fpydensity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synodriver","download_url":"https://codeload.github.com/synodriver/pydensity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244407723,"owners_count":20447841,"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":["cffi","compression","cython"],"created_at":"2024-10-10T11:26:22.356Z","updated_at":"2025-03-19T10:30:42.222Z","avatar_url":"https://github.com/synodriver.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003ci\u003e✨ pydensity ✨ \u003c/i\u003e\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003eThe python binding for \u003ca href=\"https://github.com/k0dai/density\"\u003edensity\u003c/a\u003e \u003c/h3\u003e\n\n[![pypi](https://img.shields.io/pypi/v/pydensity.svg)](https://pypi.org/project/pydensity/)\n![python](https://img.shields.io/pypi/pyversions/pydensity)\n![implementation](https://img.shields.io/pypi/implementation/pydensity)\n![wheel](https://img.shields.io/pypi/wheel/pydensity)\n![license](https://img.shields.io/github/license/synodriver/pydensity)\n![action](https://img.shields.io/github/workflow/status/synodriver/pydensity/build%20wheel)\n\n## 安装\n```bash\npip install pydensity\n```\n\n\n## 使用\n- encode\n```python\nimport pydensity\norigin = b\"121212121212121\"\nsize = pydensity.decompress_safe_size(len(origin))\ndata = pydensity.compress(origin, pydensity.Algorithm.lion)\nprint(pydensity.decompress(data, size))\n```\n\n## 公开函数\n```python\nfrom typing import Any\nimport enum\n\nclass Algorithm(enum.Enum):\n    chameleon: Any\n    cheetah: Any\n    lion: Any\n\ndef format_state(state) -\u003e str: ...\ndef major_version(): ...\ndef minor_version(): ...\ndef revision_version(): ...\ndef get_dictionary_size(algorithm: Algorithm): ...\ndef compress_safe_size(input_size: int): ...\ndef decompress_safe_size(input_size: int): ...\n\nclass Compressor:\n    c_state: Any\n    context: Any\n    def __init__(self, algorithm: Algorithm, custom_dictionary: bool) -\u003e None: ...\n    @property\n    def state(self): ...\n    def compress(self, data: bytes) -\u003e bytes: ...\n    def __del__(self) -\u003e None: ...\n\nclass DeCompressor:\n    c_state: Any\n    context: Any\n    def __init__(self, data: bytes, custom_dictionary: bool) -\u003e None: ...\n    @property\n    def state(self): ...\n    def decompress(self, data: bytes, decompress_safe_size: int) -\u003e bytes: ...\n    def __del__(self) -\u003e None: ...\n\ndef compress(data: bytes, algorithm: Algorithm) -\u003e bytes: ...\ndef compress_into(data: bytes, out: bytearray, algorithm: Algorithm) -\u003e int: ...\ndef decompress(data: bytes, decompress_safe_size: int) -\u003e bytes: ...\ndef decompress_into(data: bytes, out: bytearray) -\u003e int: ...\n```\n\n### 本机编译\n```\npython -m pip install setuptools wheel cython cffi\ngit clone https://github.com/synodriver/pydensity\ncd pydensity\ngit submodule update --init --recursive\npython setup.py bdist_wheel --use-cython --use-cffi\n```\n\n### 后端选择\n默认由py实现决定，在cpython上自动选择cython后端，在pypy上自动选择cffi后端，使用```DENSITY_USE_CFFI```环境变量可以强制选择cffi","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Fpydensity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynodriver%2Fpydensity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Fpydensity/lists"}