Skip to main content

pyomq

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

Highlights

  • Sync and asyncio APIs with all 20 ZMTP socket types.
  • Standard sockets: PAIR, PUB, SUB, REQ, REP, DEALER, ROUTER, PULL, PUSH, XPUB, XSUB, and STREAM.
  • Draft sockets: SERVER, CLIENT, RADIO, DISH, GATHER, SCATTER, PEER, and CHANNEL.
  • tcp://, ipc://, inproc://, and udp:// transports (RADIO/DISH only).
  • Optional plain, curve, lz4, and zstd features in the published wheel.
  • Built on omq-tokio; runtime work runs on a dedicated background thread and Python calls release the GIL across the runtime trip.
  • DISH groups use socket.join() / socket.leave() and multipart group messages.

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.

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

Zguide-style runnable examples live in examples/zguide/.

PLAIN servers require an explicit policy before bind. Use fixed credentials with pull.plain_server = 1; pull.set_plain_auth([("alice", "secret")]), or pass a callable to set_plain_auth. Clients keep using plain_username and plain_password. PLAIN does not encrypt traffic.

Performance

See COMPARISONS.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.93 M/s 1.57 M/s 1.87x
REQ/REP rt/s 8,161/s 4,348/s 1.88x

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 transparent compression transports on top of TCP: lz4+tcp:// and experimental zstd+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 the transport threshold are sent as-is when compression would not help.

Compression transports support static dictionaries and dictionary auto-training (off by default). Auto-training samples outbound messages, builds a 2 KiB dict, and ships it once per connection. Static dicts are set with compression_dict. zstd+tcp:// also accepts compression_level. Pure Rust (lz4rip / zrip), no C compiler required.

Enable it on sockets that send compressible traffic before bind()/connect():

push.compression_auto_train = 1
# or: push.setsockopt(zmq.OMQ_COMPRESSION_AUTO_TRAIN, 1)
push.compression_level = 1  # zstd+tcp only

See BENCHMARKS_COMPRESSION.md for throughput charts and benchmark details. Wire formats: LZ4, Zstd.

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. PeerInfo has .public_key (Z85) and
# .identity (bytes or None).
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

Metadata

Release files for pyomq 0.21.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyomq 0.21.0
File Size Uploaded
pyomq-0.21.0.tar.gz 669.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyomq 0.21.0
File
pyomq-0.21.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details
pyomq-0.21.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
pyomq-0.21.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
pyomq-0.21.0-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
pyomq-0.21.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
pyomq-0.21.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
pyomq-0.21.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
pyomq-0.21.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 15.6 MB

Release files / pyomq-0.21.0.tar.gz

Download URL pyomq-0.21.0.tar.gz
Size 669.4 kB
Tags Source
SHA-256 checksum
How to use checksums
944059796758dedc9ad27e983be2653eaca5e33779c4d2e0a6ee275fd33b00b6
BLAKE2b-256 checksum
How to use checksums
a4902cebb8f12cb43458ec0d293de255dddba89af04702e3161f19291528b980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-win_arm64.whl

Download URL pyomq-0.21.0-cp311-abi3-win_arm64.whl
Size 1.8 MB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
1dd0f6edfedd4ec1e152038e7614aff23b191d8e2d48e129a11304cd83b8ec35
BLAKE2b-256 checksum
How to use checksums
8762fbd78de1855f985fa1ed1fa7fdd3445f5b7c28993b2302d108f190bd29e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-win_amd64.whl

Download URL pyomq-0.21.0-cp311-abi3-win_amd64.whl
Size 1.9 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a3c5ae37ae1021ba8b3eaddb9e3662afbed0e2672c9480f21db657a8ad1d5448
BLAKE2b-256 checksum
How to use checksums
ea40eb82e484a9c68b1a052bcbad60902204d35bea3c3dd909f42d32d654196b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL pyomq-0.21.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 2.1 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
7f741a7b3f3366b238bbe4123f8c885e0ccfa02ff68dc49c1caf1c767a410ef7
BLAKE2b-256 checksum
How to use checksums
7211ad19b3881c5ab745a68384ad55afe810aacdbe6d3bb0450b0cc506abb4fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL pyomq-0.21.0-cp311-abi3-musllinux_1_2_aarch64.whl
Size 2.0 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
03d1849e98305f8fb5130bbcfe83c390ee6490cbc5f2f765e8fe6f3c34f0a477
BLAKE2b-256 checksum
How to use checksums
a275e9bc77e0008933e32e8bfce7b3f7176cb70482dde09613653cd79bdc79fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyomq-0.21.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.9 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f66490a7196d9cb04db6910fdbb9086116f5a701d39dae5d8bcea96a18c77be1
BLAKE2b-256 checksum
How to use checksums
e13e47982cfdfc422608adf704f85577203927d9dd748404a2ebbfc37fb5ae21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyomq-0.21.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.8 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
ab7fdefdccca090e647c1cf8d529b7563b52137eef3c48e9cd8d17519bcf1042
BLAKE2b-256 checksum
How to use checksums
c122b84086c62fe93148f08df27c47bb39ecf47855554c1505e4a0f20923d2a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL pyomq-0.21.0-cp311-abi3-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a2b6922a01e1dfc3ced59389d1933f11052843f3a43afd9eb84f3e7c4ddf90d2
BLAKE2b-256 checksum
How to use checksums
d6a3e5cf0b489d84e7c45f640f2781282fa192f00febafe873d6651082ef36b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / pyomq-0.21.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pyomq-0.21.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 1.8 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
430c5c70c8ab70879ab56330d68aa2ed1ae5c4a3bdf29ce09aecc3b70cf94904
BLAKE2b-256 checksum
How to use checksums
cd0edf63d7b48c29a199e01a38c6c1dcd658f251d78c5aa031313ee01f75c93d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release history Release notifications | RSS feed

0.26.0

9 release files

0.25.0

9 release files

0.24.0

9 release files

0.22.0

9 release files

This release

0.21.0 This release

9 release files

0.20.1

9 release files

0.20.0

9 release files

0.19.0

9 release files

0.18.3

9 release files

0.18.2

9 release files

0.18.1

9 release files

0.18.0

9 release files

0.17.1

9 release files

0.16.4

5 release files

0.16.3

5 release files

0.16.2

5 release files

0.16.1

5 release files

0.15.0

5 release files

0.12.7

5 release files

0.12.6

5 release files

0.12.5

5 release files

0.12.3

5 release files

0.12.2

5 release files

0.12.1

5 release files

0.12.0

5 release files

0.11.0

5 release files

0.10.3

5 release files

0.10.2

5 release files

0.10.0

5 release files

0.9.0

5 release files

0.8.1

5 release files

0.8.0

5 release files

0.7.1

5 release files

0.7.0

3 release files

0.6.1

3 release files

0.6.0

3 release files

0.5.0

3 release files

0.4.2

3 release files

0.4.1

3 release files

0.3.1

4 release files

0.2.4

4 release files

0.2.3

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page