zangy
A fast redis library for python written in Rust using PyO3.
Installation
pip install --user zangy
Building from source requires nightly Rust.
How does it work?
zangy aims to be the fastest python redis library. This is done by using pyo3 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.
Due 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 is used for the redis operations and tokio is used to spawn tasks outside the GIL.
Because it uses tokio and rust-level tasks, zangy unleashes maximum performance when used with a lot of concurrent things to do.
Is it fast?
Yes! 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.
Benchmark sources can be found in the bench directory.
Benchmarks below done with Redis 6.0.9 and Python 3.9, aioredis 1.3.1 and the latest zangy master:
| Task | aioredis operations/s | aioredis total time | zangy operations/s | zangy total time |
|---|---|---|---|---|
| Loop 1 million times, set key to value | 7941.61 | 2m6.054s | 8485.11 | 1m57.923s |
| Set 1 million keys at once and wait for finishing | - | 0m49.797s | - | 0m25.294s |
TLDR: zangy is faster in every regard but crushes in actually concurrent scenarios.
Usage
The API is subject to change.
import zangy
# Create a pool with 2 connections and 2 pubsub connections
pool = await zangy.create_pool("redis://localhost:6379", 2, 2)
# Generic redis commands (disadvised)
await pool.execute("SET", "a", "b")
# Individual commands
value = await pool.get("a")
# Wait for pubsub messages and echo back
with pool.pubsub() as pubsub:
await pubsub.subscribe("test1")
async for (channel, payload) in pubsub:
print(channel, payload)
await pool.publish("test2", payload)
Aliases for almost all operations exist on pool (.set, .set_ex, .zrange, etc).
What is not supported?
- Single connections. Just use a pool with 1 member.
Metadata
Release files for zangy 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zangy-0.1.2.tar.gz | 11.4 kB | Without provenance | Details for zangy-0.1.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| zangy-0.1.2-cp39-none-win_amd64.whl | CPython 3.9 | none | Windows x86-64 | Details for zangy-0.1.2-cp39-none-win_amd64.whl |
| zangy-0.1.2-cp39-cp39-manylinux2010_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.12+ x86-64 | Details for zangy-0.1.2-cp39-cp39-manylinux2010_x86_64.whl |
| zangy-0.1.2-cp38-none-win_amd64.whl | CPython 3.8 | none | Windows x86-64 | Details for zangy-0.1.2-cp38-none-win_amd64.whl |
| zangy-0.1.2-cp38-cp38-manylinux2010_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.12+ x86-64 | Details for zangy-0.1.2-cp38-cp38-manylinux2010_x86_64.whl |
Total release size: 2.2 MB
Release files / zangy-0.1.2.tar.gz
| Download URL | zangy-0.1.2.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b3ce0aea87379c7cdc1c6143ffb314c0267ed4f7ed6c074bef172c12278c175
|
|
BLAKE2b-256 checksum How to use checksums |
dad56de83a75653f5b7e4446c538a18b8a5863f3ba8ff48f62ebff30d6852b61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.10.4
|
Release files / zangy-0.1.2-cp39-none-win_amd64.whl
| Download URL | zangy-0.1.2-cp39-none-win_amd64.whl |
|---|---|
| Size | 501.8 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7cb797cc83cf3f7e1a40431dff9e8775328de74bed2af846354399f2da9baa44
|
|
BLAKE2b-256 checksum How to use checksums |
ea8bac050b0df340737363ff1a16f1f56da823b02df4233cd8ec514ee2f33b93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.10.4
|
Release files / zangy-0.1.2-cp39-cp39-manylinux2010_x86_64.whl
| Download URL | zangy-0.1.2-cp39-cp39-manylinux2010_x86_64.whl |
|---|---|
| Size | 583.7 kB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c3c1cbae9533ef9938f41bab58ab4e3c88b20955c127f9ead619916ec8672017
|
|
BLAKE2b-256 checksum How to use checksums |
3f309b4f03252f9ecc2169d02dd9b55bfc9440bc78967411f325322e098b18e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.10.4
|
Release files / zangy-0.1.2-cp38-none-win_amd64.whl
| Download URL | zangy-0.1.2-cp38-none-win_amd64.whl |
|---|---|
| Size | 501.6 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
316c4056fa52cee2bd5e95f064f3f0d3e8156baa00f8abd1d24f51bffcec7d6c
|
|
BLAKE2b-256 checksum How to use checksums |
b6a206501e9690997489a1ad8377b917b6cbe8d51cb6bec863a6b4492cf74cdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.10.4
|
Release files / zangy-0.1.2-cp38-cp38-manylinux2010_x86_64.whl
| Download URL | zangy-0.1.2-cp38-cp38-manylinux2010_x86_64.whl |
|---|---|
| Size | 583.6 kB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b8f1c7d67c2e2b92e0be798c3b845781990ef594f885545cb9b9c12b7caa5952
|
|
BLAKE2b-256 checksum How to use checksums |
cc1d37483fd9052cca2c1ec467ba9ce2b5daec68505cafbad05f5f9f8084d8ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.10.4
|
Security for zangy 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.