Skip to main content

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. Use pyomq.has("curve") at runtime to check availability.

Published wheels currently target Linux. Other platforms can build from sdist when the local Rust/Python toolchain supports them. Windows pyomq support is not complete on main yet.

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 20 ZMTP socket types are wired:

  • Standard (RFC 28 + 47): PAIR, PUB, SUB, REQ, REP, DEALER, ROUTER, PULL, PUSH, XPUB, XSUB, STREAM.
  • 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.

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-tokio (multi-threaded tokio runtime). The runtime runs on a dedicated background thread; every Python call releases the GIL across the runtime trip.

Performance

See BENCHMARKS.md for full tables.

pyomq vs pyzmq performance

2-process loopback throughput and latency vs pyzmq, measured on Linux 6.12 (Debian 13), Intel i7-8700B 3.2 GHz, Rust 1.95.0.

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

pyomq pyzmq ratio
PUSH/PULL msg/s 2.75 M/s 1.53 M/s 1.79×
REQ/REP rt/s 8,441/s 4,511/s 1.87×

pyomq's proxy() forwards directly between sockets on the tokio runtime, 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.8x faster. REQ/REP proxy is latency-bound (4 TCP hops per round-trip); pyomq is ~1.9x faster thanks to direct socket forwarding.

Run scripts/update_perf.py (after maturin develop --release) to re-measure, regenerate the chart, and update the proxy table.

Compression transports

OMQ.rs adds a transparent LZ4 compression transport on top of TCP: lz4+tcp://. 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")

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).

lz4+tcp:// supports dictionary auto-training (off by default). When enabled, it samples the first 100 outbound messages, builds a 2 KiB dict, and ships it to the peer once. After that the compression threshold drops from 512 B to 128 B, so small structured messages start compressing too. Pure Rust (lz4rip), no C compiler required.

See BENCHMARKS_COMPRESSION.md for throughput charts and benchmark details. Wire format: LZ4 transport RFC.

CURVE authentication

CURVE encrypts traffic and authenticates the server to the client. To also authenticate clients to the server, call set_curve_auth() before bind()/connect():

server_pub, server_sec = zmq.curve_keypair()
client_pub, client_sec = zmq.curve_keypair()

pull = ctx.socket(zmq.PULL)
pull.curve_server = 1
pull.curve_publickey = server_pub
pull.curve_secretkey = server_sec

# Option 1: allow specific client keys (checked in Rust, no GIL overhead)
pull.set_curve_auth([client_pub])

# Option 2: custom callback receiving a PeerInfo with a .public_key (Z85 bytes)
pull.set_curve_auth(lambda peer: peer.public_key in allowed_keys)

# Option 3: accept any valid CURVE client (the default)
pull.set_curve_auth(None)

No ZAP, no filesystem key management. The callback runs during the CURVE handshake; returning a falsy value rejects the client.

Develop

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

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.16.2.tar.gz (526.0 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.16.2-cp39-abi3-musllinux_1_2_x86_64.whl (1.8 MB view details)

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

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

pyomq-0.16.2-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.16.2-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.16.2.tar.gz.

File metadata

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

File hashes

Hashes for pyomq-0.16.2.tar.gz
Algorithm Hash digest
SHA256 8170aee9e1bda4a47117a317b070caf912df5e7d220d3e977d37ad534f2e3469
MD5 6a0a8066c8a50590ac53e80a74b9e100
BLAKE2b-256 fec7afaa0f24e5881d354adaa76fe0a1f4a588a59b4ecd5f9815b5d49473fdcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.16.2.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.16.2-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyomq-0.16.2-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 507fd65da3dd7233d3605686cddf3717da3c0994845119fe418af8bbdcba66e7
MD5 201dad2db9b0d2bf1c51775be527beac
BLAKE2b-256 63f08701e7c34e2f38b53f68179a63c37b750d520b1145803abca1b8df3b5852

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.16.2-cp39-abi3-musllinux_1_2_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.16.2-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyomq-0.16.2-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2459a32b4119280280d4ab569037180f9d2e7a95786952973a9ee496245c1df1
MD5 4c1a663a7ef8d46b939c82d4e6c1d28f
BLAKE2b-256 e0b3cd7b09422fae1ec83acffc4463ceed12287bfaebe25d359b347c0dbce117

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.16.2-cp39-abi3-musllinux_1_2_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.

File details

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

File metadata

File hashes

Hashes for pyomq-0.16.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e97586377d91024864f79b57d2250a77ae2d788c510e4d266f98bee3c5359c07
MD5 fe8a73516a028d04a5705c9aad958461
BLAKE2b-256 a2e88f4aba949338482d89e7faf5e698947c4b2706031203e68f15dec7ee3b60

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.16.2-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.16.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyomq-0.16.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c64ece045c07a0d589e4d8adeee6653bc7b3aa8985cf295edad5be9c722e27be
MD5 ed54b117f74779d3d4f138593761978d
BLAKE2b-256 3c50496a6ba7de97c41d409f0f7e10be1c6d4e06e3f7576e8b3bb090d1c2a882

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomq-0.16.2-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.

Release history Release notifications | RSS feed

0.20.1

9 files

0.20.0

9 files

0.19.2

9 files

0.19.1

9 files

0.19.0

9 files

0.18.3

9 files

0.18.2

9 files

0.18.1

9 files

0.18.0

9 files

0.17.1

9 files

0.16.4

5 files

0.16.3

5 files

This release

0.16.2 This release

5 files

0.16.1

5 files

0.15.0

5 files

0.13.0

5 files

0.12.7

5 files

0.12.6

5 files

0.12.5

5 files

0.12.3

5 files

0.12.2

5 files

0.12.1

5 files

0.12.0

5 files

0.11.0

5 files

0.10.3

5 files

0.10.2

5 files

0.10.0

5 files

0.9.0

5 files

0.8.1

5 files

0.8.0

5 files

0.7.1

5 files

0.7.0

3 files

0.6.1

3 files

0.6.0

3 files

0.5.0

3 files

0.4.2

3 files

0.4.1

3 files

0.3.1

4 files

0.2.4

4 files

0.2.3

2 files

0.2.1

2 files

0.2.0

2 files

Supported by

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