Skip to main content

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

PyPI version License

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 (iterator protocol for 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())

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

pyrkafka-0.2.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyrkafka-0.2.1-cp313-abi3-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13+Windows x86-64

pyrkafka-0.2.1-cp313-abi3-manylinux_2_28_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.28+ ARM64

pyrkafka-0.2.1-cp313-abi3-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

pyrkafka-0.2.1-cp313-abi3-macosx_10_12_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

pyrkafka-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

File details

Details for the file pyrkafka-0.2.1.tar.gz.

File metadata

  • Download URL: pyrkafka-0.2.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyrkafka-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8d12dc1df1f60acd9e6a67ff991beb1db5fda7532311ce0cc5390cb6f06289ef
MD5 f0eaea106ced1bade9b3eba997069257
BLAKE2b-256 cf8629e45018dae06ac85e703130a4cb2198b4f1c42a3f26ae596b132b1c9c9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrkafka-0.2.1.tar.gz:

Publisher: release.yaml on Miggets7/pyrkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrkafka-0.2.1-cp313-abi3-win_amd64.whl.

File metadata

  • Download URL: pyrkafka-0.2.1-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

Hashes for pyrkafka-0.2.1-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 eb8458afc8b3069f7b87e6b15ec24f874886b84842e342e22638c4838a6e1b44
MD5 f80f42bcd2767473331377b94ad31bf0
BLAKE2b-256 3b5e31040517388db883cd46ac15bbafaf61743810866005f3296df953104964

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrkafka-0.2.1-cp313-abi3-win_amd64.whl:

Publisher: release.yaml on Miggets7/pyrkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrkafka-0.2.1-cp313-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyrkafka-0.2.1-cp313-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 62a70fca61f15f1c8611c25c392104c7547f6eb75d6a711a121c0a201314583d
MD5 2f257db84fb6b564753659baa9844c97
BLAKE2b-256 24f14751f2b85630de73edc3f6715d00e33a37db770f597009d1283d5db4783d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrkafka-0.2.1-cp313-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yaml on Miggets7/pyrkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrkafka-0.2.1-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrkafka-0.2.1-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ee2c40ce011f6210e7890d9cfb75083ac513653d8d94a7d7ffda911d4b306fe
MD5 f0d7da53ca9b9b73cfa40271c7f5225a
BLAKE2b-256 776f434e049d591bf6ea5244ad0c9eb18114c1c5fa86dd914b201152b9677ed4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrkafka-0.2.1-cp313-abi3-macosx_11_0_arm64.whl:

Publisher: release.yaml on Miggets7/pyrkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrkafka-0.2.1-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyrkafka-0.2.1-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bd3920a4f48992fb1888f225d0099e12c06881dbb2dbcdee21af45c09ea7911c
MD5 5993ea8a64a0fd5d5d56b338f8dc916f
BLAKE2b-256 26e29cb1f1aa856dc55fc1e6df06dfb8ad17f924c6b5a0ae17268ab836e4bb55

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrkafka-0.2.1-cp313-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yaml on Miggets7/pyrkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrkafka-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrkafka-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3891e24644fcad2e5a6903be022b9936cd0f7d52999055368440a42097e848ac
MD5 9bf01fe1e6403c63333633104122f4ce
BLAKE2b-256 d474d16df9fe6bc7fc26035eb68327514e717c71e9436d49383a6ccc82ccbc94

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrkafka-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: release.yaml on Miggets7/pyrkafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page