Skip to main content

zloop

[!WARNING] zloop is experimental. The API and behaviour may change at any time, and it is not yet ready for production use.

A drop-in asyncio event loop whose engine is written in Zig. It's to asyncio what uvloop is - a real asyncio.AbstractEventLoop - except the engine is hand-written in Zig (a kqueue/epoll reactor, plus an opt-in io_uring backend on Linux) rather than libuv wrapped in Cython.

import asyncio
import zloop

print(asyncio.run(asyncio.sleep(0, "hello from a Zig loop"), loop_factory=zloop.new_event_loop))

With uvicorn:

uvicorn app:app --loop zloop:new_event_loop

Why

  • Drop-in. A genuine AbstractEventLoop, so the asyncio ecosystem - uvicorn, FastAPI, AnyIO, HTTPX2 - runs on it unchanged.
  • Correct. Passes uvicorn's entire test suite (1048 tests), identical to stock asyncio, plus its own suite at 100% coverage.
  • Fast. The hot paths - scheduling, timers, and socket I/O - run in Zig, not Python. See Performance for benchmarks against asyncio and uvloop, including an opt-in io_uring backend for free-threaded CPython.

Performance

The fairest comparison is uvloop's own echo benchmark, run unchanged except for a --zloop server flag mirroring --uvloop (the client is byte-for-byte uvloop's). Requests/sec, higher is better.

zloop has two backends: the default readiness reactor (epoll/kqueue) and an opt-in io_uring completion backend (ZLOOP_IO_URING=completion, Linux only). Both are shown below; the fastest in each row is bold.

Single loop (the default, GIL on)

Linux, CPython 3.14, 3 workers, best of 3, requests/sec:

Echo throughput: uvloop vs zloop across server modes and message sizes

mode size asyncio uvloop zloop epoll zloop io_uring
proto 1 KB 135,393 127,872 132,223 138,778
proto 100 KiB 61,441 57,158 66,188 22,280
streams 1 KB 105,250 116,043 122,236 116,720
streams 100 KiB 43,312 40,582 46,862 19,679

For a single GIL-bound loop the default epoll backend beats uvloop. The io_uring completion backend is slower here - its submit/reap overhead and the 64 KiB buffer-ring copy aren't amortized when one serialized loop is the bottleneck (it fragments 100 KiB messages badly). Completion's win is parallel free-threaded loops, below.

Free-threaded parallel loops (GIL off)

Under free-threaded CPython (3.14t), N independent loops on N threads stop being serialized by the GIL - and the leaner completion path (batched submits, multishot recv, ring writes, cached data_received) beats uvloop at every thread count. 1 KB messages, 8 conns/thread, requests/sec:

Free-threaded throughput: uvloop vs zloop epoll vs zloop io_uring across parallel loops

loops uvloop zloop epoll zloop io_uring
1 174,185 163,900 209,071
4 606,261 535,556 742,847
8 934,289 783,205 1,142,655
16 1,148,609 815,971 1,182,234

(Linux io_uring kernel 6.10, 3-sample medians on a 12-CPU host; directional - measured in a VM, not bare metal. The 16-loop margin is thin: 16 loops oversubscribe 12 cores.)

Reproduce the single-loop matrix with scripts/bench; the free-threaded numbers come from bench_uvloop/ft_parallel_bench.py on a python3.14t build. Full tables and caveats are in the performance docs.

How it works

The loop engine lives in Zig; CPython is reused only where reimplementing would be reckless: driving coroutines (asyncio.Future / asyncio.Task) and the TLS state machine (asyncio.sslproto). That's exactly uvloop's boundary.

zloop/            Python edge - new_event_loop() factory, connection setup
src/python/*.zig  CPython C-API adapter - Loop, Handle, Transport
src/core/*.zig    pure-Zig domain - run-once engine, kqueue/epoll reactor, timer heap

Metadata

Release files for zloop 0.0.1

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

Source distribution (sdist)

Source distribution for zloop 0.0.1
File Size Uploaded
zloop-0.0.1.tar.gz 57.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for zloop 0.0.1
File
zloop-0.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
zloop-0.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
zloop-0.0.1-cp314-cp314-macosx_11_0_x86_64.whl CPython 3.14 CPython 3.14 macOS 11.0+ x86-64 Details
zloop-0.0.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
zloop-0.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
zloop-0.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
zloop-0.0.1-cp313-cp313-macosx_11_0_x86_64.whl CPython 3.13 CPython 3.13 macOS 11.0+ x86-64 Details
zloop-0.0.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
zloop-0.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
zloop-0.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
zloop-0.0.1-cp312-cp312-macosx_11_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 11.0+ x86-64 Details
zloop-0.0.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 2.8 MB

Release files / zloop-0.0.1.tar.gz

Download URL zloop-0.0.1.tar.gz
Size 57.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6319a0109522d6d6f8982e856efb03068e56e0eb54d376b1c43bc4026334fe73
BLAKE2b-256 checksum
How to use checksums
d074e5339af11a5f0d94c068e4e0a9d5dcc3a82551f4fd7e7b5bc21a8ba5ed17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zloop-0.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 601.4 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3e1dfa7592f6221fb958f4becab769577aae8d222987882ad72963c9858d72a5
BLAKE2b-256 checksum
How to use checksums
7719a7f09eb952b019d07fc26d40c94eb87b2f061ee3cc42b8d3483f8d2f025f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL zloop-0.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 551.5 kB
Tags CPython 3.14 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
d9d3e6c51551cff25f9fb558894829f5845d1603e25461782959159524cbed28
BLAKE2b-256 checksum
How to use checksums
5c73ed938dd5e7c2b74c9fba722dac598c6675418d933855dd4ad8ecead5f44f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp314-cp314-macosx_11_0_x86_64.whl

Download URL zloop-0.0.1-cp314-cp314-macosx_11_0_x86_64.whl
Size 107.6 kB
Tags CPython 3.14 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
ff460d454ef4c00e67ea99385acb48be1c1b1ff2e28fc65e8ac5b4f72223db3d
BLAKE2b-256 checksum
How to use checksums
e47bf3745a3d4507036c97ca115a93643d70fb94b513ef6c93017590f8b2341c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL zloop-0.0.1-cp314-cp314-macosx_11_0_arm64.whl
Size 109.6 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
96463bcd13eae294eab28c4744d75092ab38a339281c4763d602d76d111a662e
BLAKE2b-256 checksum
How to use checksums
fc77da45950ac6cb03c2da21f396a66ac5ed76e127aa6b38585df5c95c85e893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zloop-0.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 404.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5e370db4bfdda062a9b32749b46dab8bc16cead3cd29189ba6d363b05d71f8e9
BLAKE2b-256 checksum
How to use checksums
1433b004c932633240787ea6161f37500f81088cba0409fc65f8825d44cc572e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL zloop-0.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 371.6 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
3194f01b6da88d7b066c9298b7565ea778a832f2295c37833b97f1ad885942f2
BLAKE2b-256 checksum
How to use checksums
5fb4be387f54861d2c4e79290094ab48740cfc1d7c7f2532ba438545dd02b701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp313-cp313-macosx_11_0_x86_64.whl

Download URL zloop-0.0.1-cp313-cp313-macosx_11_0_x86_64.whl
Size 75.1 kB
Tags CPython 3.13 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
4a2c10b36e463ee28eb5b483928f8175b1cbba5aa658767a862109f69b66c51e
BLAKE2b-256 checksum
How to use checksums
c25d3989246aed014a8230ac01c0a923f097a252b9abff7726d9176849a9b2d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL zloop-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
Size 77.1 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
46e97657f5de5a6e8cffe46bb5d0e7d4d70ced9b08522e40d243452def6cfaf4
BLAKE2b-256 checksum
How to use checksums
83d2650c8e8edb9372be0cb5bd26cb5cdfce967484e2ce51b352d7d8f5a528e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL zloop-0.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 208.5 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6340a676efb387363cbf2d4463280a980d2d14beeffdb60e9c72c5ee2ef76e4f
BLAKE2b-256 checksum
How to use checksums
84b5aa47adb68c48ec283314326c81e156d7a91d5c211c0d91bbf3621769f108
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL zloop-0.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 191.8 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
fd5133cfc7934c011447d96720914f5e66009cf60aa6397a3780a77045a9b975
BLAKE2b-256 checksum
How to use checksums
ed9407bcaeaf7b5da8725742a5b31cc77c24612f2d56256ac73f00545efaa13e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp312-cp312-macosx_11_0_x86_64.whl

Download URL zloop-0.0.1-cp312-cp312-macosx_11_0_x86_64.whl
Size 42.6 kB
Tags CPython 3.12 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
e5f3c7df0a24e0cf7e800a67f01bc96cb17bcdfd311366d497a4f74379df2efd
BLAKE2b-256 checksum
How to use checksums
e201b9884ea67c0a3f9e1e7e6fd3eaac5ee9e2dc990e51aad5c83d3034e6b599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / zloop-0.0.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL zloop-0.0.1-cp312-cp312-macosx_11_0_arm64.whl
Size 44.6 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0617e8054285222226e70fd11752408f1fad58895af74fc155969a1b44d123ab
BLAKE2b-256 checksum
How to use checksums
0de2b9120e15d62382aa2fd2e74f859cff364c4e9dd99c45bb396b6130f18a05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.0.1 This release

13 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