Skip to main content

Python binding for omq.rs (Rust libzmq port). Drop-in pyzmq replacement on the common path.

Project description

pyomq

Python binding for omq.rs, a Rust libzmq port. Drop-in pyzmq replacement on the common path.

Install

uv pip install pyomq
uv pip install 'pyomq[test]'   # adds pytest, pyzmq for the interop suite

The published wheel includes optional features: plain, curve, lz4, zstd. Use pyomq.has("curve") at runtime to check availability.

Usage

import pyomq as zmq  # drop-in for `import zmq` from pyzmq

ctx = zmq.Context()
push = ctx.socket(zmq.PUSH)
push.connect("tcp://127.0.0.1:5555")
push.send(b"hello")
push.close()
ctx.term()

For asynchronous code:

import pyomq
import pyomq.asyncio as zmq_async

ctx = zmq_async.Context()
sock = ctx.socket(pyomq.PUSH)
await sock.connect("tcp://127.0.0.1:5555")
await sock.send(b"hello")
await sock.close()

Status

Sync and asyncio APIs both ship in this release. All 19 ZMTP socket types are wired:

  • Standard (RFC 28 + 47): PAIR, PUB, SUB, REQ, REP, DEALER, ROUTER, PULL, PUSH, XPUB, XSUB.
  • Draft: SERVER, CLIENT (RFC 41), RADIO, DISH (RFC 48), GATHER, SCATTER (RFC 49), PEER, CHANNEL (RFC 51).

Transports: tcp://, ipc://, inproc://, and udp:// (RADIO/DISH only). Optional features built into the wheel: plain, curve, lz4, zstd.

DISH groups: use socket.join(b"group") / socket.leave(b"group") to manage subscriptions; messages are sent as multipart [group, body].

Backend

pyomq is built on omq-compio (single-threaded io_uring on Linux). The runtime runs on a dedicated background thread; every Python call releases the GIL across the runtime trip. This is the only backend pyomq supports — the omq-tokio backend exists in the upstream Rust workspace for callers that need a multi-thread tokio integration, but pyomq's per-call overhead is shaped around compio's single-thread invariant.

Performance

See BENCHMARKS.md for full tables.

PUSH/PULL throughput: Python bindings

Loopback PUSH/PULL throughput vs pyzmq, on a Linux 6.12 (Debian 13) VM on an Intel Mac Mini 2018 (i7-8700B, 3.2 GHz), Rust 1.95.0, default features:

Size inproc pyomq inproc pyzmq ratio tcp pyomq tcp pyzmq ratio
8 B 1.30 M/s 627 k/s 2.08× 1.36 M/s 565 k/s 2.41×
32 B 1.29 M/s 620 k/s 2.08× 1.36 M/s 576 k/s 2.37×
128 B 1.31 M/s 516 k/s 2.54× 1.29 M/s 496 k/s 2.61×
512 B 1.29 M/s 480 k/s 2.69× 1.21 M/s 461 k/s 2.62×
2 KiB 1.17 M/s 461 k/s 2.54× 908 k/s 342 k/s 2.65×
8 KiB 1.04 M/s 368 k/s 2.83× 349 k/s 102 k/s 3.41×
32 KiB 622 k/s 196 k/s 3.17× 116 k/s 46 k/s 2.50×
128 KiB 203 k/s 70 k/s 2.91× 32 k/s 24 k/s 1.32×

zmq.proxy() forwarding (128 B, TCP)

pyomq pyzmq ratio
PUSH/PULL msg/s 963 k/s 520 k/s 1.85×
REQ/REP rt/s 8,764/s 6,521/s 1.34×

pyomq's proxy() runs as a native Rust async loop on the compio thread — no Python per-message overhead. pyzmq's zmq.proxy() calls libzmq's C-level zmq_proxy. PUSH/PULL forwarding is throughput-bound and pyomq is ~1.9× faster. REQ/REP is latency-bound (4 TCP hops per round-trip) so both are similar.

Run scripts/update_perf.py (after maturin develop --release) to re-measure and update the tables above.

Compression transports

OMQ.rs adds two transparent compression transports on top of TCP: lz4+tcp:// (fast, low-latency) and zstd+tcp:// (higher ratio, better for large or structured payloads). Swap the scheme in your endpoint string and everything else stays the same:

push = ctx.socket(zmq.PUSH)
push.bind("lz4+tcp://127.0.0.1:5555")   # or zstd+tcp://

pull = ctx.socket(zmq.PULL)
pull.connect("lz4+tcp://127.0.0.1:5555")

Both peers must use a matching compression endpoint. Payloads below ~512 B are sent as-is (the codec detects that compression would expand them). For realistic JSON payloads at 2 KiB, lz4 yields ~3.8× and zstd ~4.5× on a bandwidth-limited link.

zstd+tcp:// also auto-trains a dictionary: it samples the first 1000 outbound messages (or 100 KiB of plaintext, whichever comes first), builds an 8 KiB dict, and ships it to the peer once. After that the compression threshold drops from 512 B to 64 B, so small structured messages start compressing too. lz4+tcp:// does not auto-train (LZ4 has no standard dict trainer).

Virtual throughput on bandwidth-limited links (JSON payloads, compio backend):

Compression throughput at 1 Gbps

Compression throughput at 100 Mbps

See BENCHMARKS_COMPRESSION.md for full tables including dict-trained ratios.

Develop

cd bindings/pyomq
uv venv && source .venv/bin/activate
uv pip install maturin pytest pyzmq
maturin develop --release
pytest -v

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

pyomq-0.7.1.tar.gz (339.8 kB view details)

Uploaded Source

Built Distributions

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

pyomq-0.7.1-cp39-abi3-musllinux_1_2_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

pyomq-0.7.1-cp39-abi3-musllinux_1_2_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

pyomq-0.7.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

pyomq-0.7.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

File details

Details for the file pyomq-0.7.1.tar.gz.

File metadata

  • Download URL: pyomq-0.7.1.tar.gz
  • Upload date:
  • Size: 339.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyomq-0.7.1.tar.gz
Algorithm Hash digest
SHA256 20dd20dac93b3b0a68221fe65d364bdbad7ab5665f5ea731e056b6736f4fc382
MD5 543e2b6c235423b845e6566c7f7c07c0
BLAKE2b-256 cf038cf661fd10e9e4128570d6db92bf383f37a5005d0e6a9ec5bb24232039f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.7.1.tar.gz:

Publisher: release-pyomq.yml on paddor/omq.rs

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

File details

Details for the file pyomq-0.7.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyomq-0.7.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ce9d1fd9ccb1b6ea9161a98ada956cbe05de691d2f424d226d07e7fbc6af08ca
MD5 055f0e07ca01362cbe1181fbb1db2747
BLAKE2b-256 5e9e233a1235a601355e4cd59822c2bef34622e6dd82b163b217922e26e4590d

See more details on using hashes here.

File details

Details for the file pyomq-0.7.1-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyomq-0.7.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e944be63d74857694dc05e9a43aa4d5ea4d5d7190f76763914829c3ae9a3f849
MD5 29ba36398616a7f6f1b05bf095196ea9
BLAKE2b-256 9f2252e19e4bfe642577cd3b032d393303de75c1a1709d0430d258ec30f8d6b4

See more details on using hashes here.

File details

Details for the file pyomq-0.7.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyomq-0.7.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c4840637bb4c9f62db73dfe22f66a1dc10cfa4599416a579a5ac92637e1c422
MD5 78665e1f910b225ea7106f0521d5878e
BLAKE2b-256 e887ad0973b551680c3575b8f1a183c1bd0cc5993a5ec29cfd9e67b6647f0cbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.7.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pyomq.yml on paddor/omq.rs

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

File details

Details for the file pyomq-0.7.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyomq-0.7.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 47fefd92fbf7831d752c1139feafdf80623ac918556f06a7233677ddad19c966
MD5 b4c4d996d27a3a55ee48f7fc4233bf98
BLAKE2b-256 20f1e3e6a0f8d3c4f709f51d157599e8b1a8d4a40e71cd9c968b39b5cac7fea6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.7.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-pyomq.yml on paddor/omq.rs

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