{"id":24115052,"url":"https://github.com/gelbpunkt/zangy","last_synced_at":"2025-09-18T04:30:45.258Z","repository":{"id":38332004,"uuid":"279136147","full_name":"Gelbpunkt/zangy","owner":"Gelbpunkt","description":"A fast redis library for python and asyncio written in Rust","archived":false,"fork":false,"pushed_at":"2024-07-24T12:32:46.000Z","size":140,"stargazers_count":23,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-15T19:21:09.493Z","etag":null,"topics":["pyo3","python","redis","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gelbpunkt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-12T19:43:45.000Z","updated_at":"2024-12-04T22:15:15.000Z","dependencies_parsed_at":"2023-02-18T12:45:49.533Z","dependency_job_id":null,"html_url":"https://github.com/Gelbpunkt/zangy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gelbpunkt%2Fzangy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gelbpunkt%2Fzangy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gelbpunkt%2Fzangy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gelbpunkt%2Fzangy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gelbpunkt","download_url":"https://codeload.github.com/Gelbpunkt/zangy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233446239,"owners_count":18677484,"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":["pyo3","python","redis","rust"],"created_at":"2025-01-11T05:36:22.604Z","updated_at":"2025-09-18T04:30:39.995Z","avatar_url":"https://github.com/Gelbpunkt.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zangy\n\nA fast redis library for python written in Rust using PyO3.\n\n## Installation\n\n`pip install --user zangy`\n\nBuilding from source requires nightly Rust.\n\n## How does it work?\n\nzangy aims to be the fastest python redis library. This is done by using [pyo3](https://pyo3.rs) to generate shared objects in binary form. It is pretty much identical to writing this in C, but less of a pain to compile and identical in speed.\n\nDue to being completely in Rust, zangy can't do lifetime-based connection pooling and instead will create connections on startup and not lazily. All actions are distributed over the pool based on round robin. Internally, [redis-rs](https://github.com/mitsuhiko/redis-rs) is used for the redis operations and [tokio](https://github.com/tokio-rs/tokio) is used to spawn tasks outside the GIL.\n\nBecause it uses tokio and rust-level tasks, zangy unleashes maximum performance when used with a _lot_ of concurrent things to do.\n\n## Is it fast?\n\nYes! It beats similar Python libraries by a fair margin. Tokio, no GIL lock and the speed of Rust especially show when setting 1 million keys _in parallel_.\n\nBenchmark sources can be found in the `bench` directory.\n\nBenchmarks below done with Redis 7.2.5 and Python 3.12.4, redis-py 5.0.7 and the latest zangy master using a pool with 10 connections:\n\n| Task                     | redis-py                       | zangy    |\n| ------------------------ | ------------------------------ | -------- |\n| 1.000.000 sequential GET | 1min 27s                       | 54s      |\n| 1.000.000 sequential SET | 1min 25s                       | 58s      |\n| 1.000.000 parallel SET   | Didn't terminate in 45mins     | 9s       |\n\nTLDR: zangy is faster in every regard but crushes in actually concurrent scenarios.\n\n## Usage\n\nThe API is subject to change.\n\n```py\nimport zangy\n# Create a pool with 2 connections and 2 pubsub connections\npool = await zangy.create_pool(\"redis://localhost:6379\", 2, 2)\n# Generic redis commands (disadvised)\nawait pool.execute(\"SET\", \"a\", \"b\")\n# Individual commands\nvalue = await pool.get(\"a\")\n\n# Wait for pubsub messages and echo back\nwith pool.pubsub() as pubsub:\n    await pubsub.subscribe(\"test1\")\n    async for (channel, payload) in pubsub:\n        print(channel, payload)\n        await pool.publish(\"test2\", payload)\n```\n\nAliases for almost all operations exist on pool (`.set`, `.set_ex`, `.zrange`, etc).\n\n## What is not supported?\n\n- Single connections. Just use a pool with 1 member.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgelbpunkt%2Fzangy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgelbpunkt%2Fzangy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgelbpunkt%2Fzangy/lists"}