{"id":19084328,"url":"https://github.com/coghost/ibloom","last_synced_at":"2025-06-20T14:09:51.631Z","repository":{"id":62570124,"uuid":"299495086","full_name":"coghost/ibloom","owner":"coghost","description":"cython bloom filter","archived":false,"fork":false,"pushed_at":"2020-09-29T10:52:36.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T21:06:26.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coghost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-29T03:29:51.000Z","updated_at":"2020-09-29T10:52:38.000Z","dependencies_parsed_at":"2022-11-03T17:15:33.267Z","dependency_job_id":null,"html_url":"https://github.com/coghost/ibloom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coghost/ibloom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fibloom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fibloom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fibloom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fibloom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coghost","download_url":"https://codeload.github.com/coghost/ibloom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coghost%2Fibloom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260959024,"owners_count":23088809,"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":[],"created_at":"2024-11-09T02:50:54.571Z","updated_at":"2025-06-20T14:09:46.609Z","avatar_url":"https://github.com/coghost.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ibloom\n\n\nthis is a fork of [pyreBloom-ng](https://github.com/leovp/pyreBloom-ng), pyreBloom-ng is a python library which implements a Redis-backed Bloom filter.\n\npyreBloom-ng is really powerful. but it's setup.py and tests and bench/benchmark.py are all outdated, the repo's last commit is 4 years ago.\n\nbased on pyreBloom-ng and added supported for python3's str, avoid of annoying *`b'some_key'`*\n\n## Installation\n\n### pre-requirement\n`ibloom` requires `hiredis` library, `Cython` and `a C compiler`\n\n\n\u003e hiredis\n\n```sh\n# Mac\nbrew install hiredis\n\n# ubuntu\napt-get install libhiredis-dev\n\n# From source:\ngit clone https://github.com/redis/hiredis\ncd hiredis \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\n\u003e Cython\n\n```sh\npip install Cython\n```\n\n## Startup\n\n### init an instance\n\n```python\nfrom ibloom import IBloom\nib = IBloom('ibloomI', 1000, 0.01, '127.0.0.1', 6383)\n```\nor\n```python\nfrom ibloom import IBloom\nib_n = IBloom(key='ibloomN', capacity=1000, error=0.01, host='127.0.0.1', port=6383)\n```\n\n### check basic info\n\n```python\n# You can find out how many bits this will theoretically consume\n\u003e\u003e\u003e ib.bits\n9585\n# And how many hashes are needed to satisfy the false positive rate\n\u003e\u003e\u003e ib.hashes\n7\n# find all available bloom filter keys\n\u003e\u003e\u003e ib.keys()\n['ibloomI.0']\n```\n\n### add data\n\n#### add all supplied\n\n```python\n# Add one value at a time (slow)\n\u003e\u003e\u003e ib.add('first')\nTrue\n# Or use batch operations (faster).\n\u003e\u003e\u003e ib.update([f'{x}' for x in range(5)])\n5\n# Alternative: ib += data, but this will return nothing\n\u003e\u003e\u003e ib += [f'{x + 5}' for x in range(5)]\n```\n\n#### only add if not exist\n\n```python\n# will first get the difference, and then update them to redis, and return them\n\u003e\u003e\u003e ib.update_difference(['5', '6', '7', '8', '9', '10'])\n['10']\n```\n\n### check if key exists\n\n#### find one\n\n```python\n# Test one value at a time (slow).\n# . in ...\n\u003e\u003e\u003e 'first' in ib\nTrue\n# ...contains(.)\n\u003e\u003e\u003e ib.contains('first')\nTrue\n```\n\n#### find multiple\n\n```python\n# Use batch operations (faster).\n# Note: ibloom.intersection() returns a list of values\n# which are found in a Bloom filter. It makes sense when\n# you consider it a set-like operation.\n\u003e\u003e\u003e ib.intersection(['3', '4', '5', '6'])\n['3', '4', '5', '6']\n# Alternative: ib \u0026 [b'3', b'4', b'5', b'6']\n\u003e\u003e\u003e ib \u0026 ['3', '4', '5', '6', '9', '10']\n['3', '4', '5', '6', '9']\n```\n\n#### find non exist\n\n```python\n\u003e\u003e\u003e ib.difference(['5', '6', '7', '8', '9', '10'])\n['10']\n# not recommended, maybe update in the future\n# Alternative: ib ^ ['5', '6', '7', '8', '9', '10']\n\u003e\u003e\u003e ib ^ ['5', '6', '7', '8', '9', '10']\n['10']\n```\n\n### delete the bloom key\n\n```python\n# delete self\nib.delete()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoghost%2Fibloom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoghost%2Fibloom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoghost%2Fibloom/lists"}