Fast Python Kafka client powered by Rust and librdkafka — producer and consumer with native performance
Project description
pyrkafka: Fast Python Kafka Client Powered by Rust
pyrkafka is a fast, lightweight Python client for Apache Kafka, built on top of librdkafka via the Rust rdkafka crate. It provides a simple, Pythonic API for producing and consuming Kafka messages with native Rust performance through PyO3.
Features
- Rust-powered performance — wraps librdkafka through Rust, avoiding the overhead of pure-Python implementations
- GIL release during polling — consumer polling releases the Python GIL, allowing other threads to run while waiting for messages
- Simple Pythonic API — producer and consumer with familiar Python patterns (
forandasync forfor consuming) - Full librdkafka configuration — pass any librdkafka config option via a dict
- SSL and compression built-in — compiled with SSL (vendored OpenSSL) and zstd compression support
- Cross-platform wheels — pre-built for Linux (x86_64, aarch64), macOS (x86_64, Apple Silicon), and Windows
Installation
pip install pyrkafka
Requires Python 3.13+. Pre-built wheels are available for all major platforms — no Rust toolchain needed for installation.
Getting Started
Producing Messages
from pyrkafka import PyrKafkaProducer
producer = PyrKafkaProducer("localhost:9092")
# Send a message (partitioned round-robin)
producer.produce("my_topic", b"Hello, Kafka!")
# Send with a key (messages with the same key go to the same partition)
producer.produce_with_key("my_topic", b"Hello, Kafka!", "my_key")
# Flush pending messages (also happens automatically when the producer is dropped)
producer.flush()
Consuming Messages
from pyrkafka import PyrKafkaConsumer
consumer = PyrKafkaConsumer("localhost:9092", "my_topic", "my_group")
for message in consumer:
print(message.decode())
Async Consuming
The consumer supports async for for use in asyncio applications. The blocking Kafka poll is automatically offloaded to a thread so the event loop stays responsive:
import asyncio
from pyrkafka import PyrKafkaConsumer
async def main():
consumer = PyrKafkaConsumer("localhost:9092", "my_topic", "my_group")
async for message in consumer:
print(message.decode())
asyncio.run(main())
Custom Configuration
Both producer and consumer accept an optional config dict for additional librdkafka configuration:
producer = PyrKafkaProducer("localhost:9092", config={
"message.timeout.ms": "5000",
"compression.type": "zstd",
})
consumer = PyrKafkaConsumer("localhost:9092", "my_topic", "my_group", config={
"auto.offset.reset": "latest",
"enable.auto.commit": "false",
})
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrkafka-0.3.0.tar.gz.
File metadata
- Download URL: pyrkafka-0.3.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2d4f7f4e213389590f4a1a5b1968ece711b1ed91c85dd27f92670ab396fe903
|
|
| MD5 |
2121ec462a13e96a751aaa34d70df00a
|
|
| BLAKE2b-256 |
7b1aa5c6559ac97df5e95eb1f16e786754eb59008c62f1dd9f4d29c69ef705f8
|
Provenance
The following attestation bundles were made for pyrkafka-0.3.0.tar.gz:
Publisher:
release.yaml on Miggets7/pyrkafka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrkafka-0.3.0.tar.gz -
Subject digest:
b2d4f7f4e213389590f4a1a5b1968ece711b1ed91c85dd27f92670ab396fe903 - Sigstore transparency entry: 1180758424
- Sigstore integration time:
-
Permalink:
Miggets7/pyrkafka@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyrkafka-0.3.0-cp313-abi3-win_amd64.whl.
File metadata
- Download URL: pyrkafka-0.3.0-cp313-abi3-win_amd64.whl
- Upload date:
- Size: 3.5 MB
- Tags: CPython 3.13+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c33ed5a350093bc25c19da445d557ec28b0221f4fc123160ec0abbb5d21fc32e
|
|
| MD5 |
34932880177d428155869b5b8944b0a0
|
|
| BLAKE2b-256 |
d1d2b7bb608cc2bf8e94d24ce0db1db7c3397f17193aec146aca6dabb85756e0
|
Provenance
The following attestation bundles were made for pyrkafka-0.3.0-cp313-abi3-win_amd64.whl:
Publisher:
release.yaml on Miggets7/pyrkafka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrkafka-0.3.0-cp313-abi3-win_amd64.whl -
Subject digest:
c33ed5a350093bc25c19da445d557ec28b0221f4fc123160ec0abbb5d21fc32e - Sigstore transparency entry: 1180758521
- Sigstore integration time:
-
Permalink:
Miggets7/pyrkafka@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyrkafka-0.3.0-cp313-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pyrkafka-0.3.0-cp313-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.13+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3bb3c956dac5382ab66c915457369c5e7f9e67d1755d007bd844ab6cadbc9aa
|
|
| MD5 |
03044bd2e9e65e0318c8ce58db0b744a
|
|
| BLAKE2b-256 |
b3bd248e5bbad6691167ebdd0d3f0d78bfd3cd78f9649588b5ce9395875053ea
|
Provenance
The following attestation bundles were made for pyrkafka-0.3.0-cp313-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release.yaml on Miggets7/pyrkafka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrkafka-0.3.0-cp313-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
f3bb3c956dac5382ab66c915457369c5e7f9e67d1755d007bd844ab6cadbc9aa - Sigstore transparency entry: 1180758494
- Sigstore integration time:
-
Permalink:
Miggets7/pyrkafka@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyrkafka-0.3.0-cp313-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyrkafka-0.3.0-cp313-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.13+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5266f4692c192fcc1e4364000b76181d2193969397f6d385101faf334475e5b
|
|
| MD5 |
89f221052df2ed3c5a2005c689799af5
|
|
| BLAKE2b-256 |
637ef5954fece9d90ab3ceea0eaec53ce3efc0bad52ceae9ad4156bb13c7edb6
|
Provenance
The following attestation bundles were made for pyrkafka-0.3.0-cp313-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yaml on Miggets7/pyrkafka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrkafka-0.3.0-cp313-abi3-macosx_11_0_arm64.whl -
Subject digest:
e5266f4692c192fcc1e4364000b76181d2193969397f6d385101faf334475e5b - Sigstore transparency entry: 1180758508
- Sigstore integration time:
-
Permalink:
Miggets7/pyrkafka@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyrkafka-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyrkafka-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.13+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b356312abcca30a236c73961f6b638d3f1ae1ead12a9628324150ebed1dc3e8
|
|
| MD5 |
e2282aec107c24be3b27bb178ce87af8
|
|
| BLAKE2b-256 |
0c9943a3c33b035f2132eff88287a823430703f05c91fe65724ffd3a83d4ed61
|
Provenance
The following attestation bundles were made for pyrkafka-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yaml on Miggets7/pyrkafka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrkafka-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl -
Subject digest:
9b356312abcca30a236c73961f6b638d3f1ae1ead12a9628324150ebed1dc3e8 - Sigstore transparency entry: 1180758448
- Sigstore integration time:
-
Permalink:
Miggets7/pyrkafka@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyrkafka-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyrkafka-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb070be0c063dd296c81e6a0b9e10913ae22dd8744f8e0cf694a9a6fc46bdad7
|
|
| MD5 |
e7468d2bfa81249d498332ca99678bc7
|
|
| BLAKE2b-256 |
ab5d88c7927a42ac9774e4321eb49ce23a3732bf277e8a008a69a04e984fb0f6
|
Provenance
The following attestation bundles were made for pyrkafka-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl:
Publisher:
release.yaml on Miggets7/pyrkafka
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrkafka-0.3.0-cp312-cp312-manylinux_2_28_x86_64.whl -
Subject digest:
fb070be0c063dd296c81e6a0b9e10913ae22dd8744f8e0cf694a9a6fc46bdad7 - Sigstore transparency entry: 1180758467
- Sigstore integration time:
-
Permalink:
Miggets7/pyrkafka@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9edb3a2b3600b5df025499b34dcc19807d38b332 -
Trigger Event:
push
-
Statement type: