An asyncio event loop with a Zig core.
Project description
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:
| 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:
| 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zloop-0.0.1.tar.gz.
File metadata
- Download URL: zloop-0.0.1.tar.gz
- Upload date:
- Size: 57.3 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6319a0109522d6d6f8982e856efb03068e56e0eb54d376b1c43bc4026334fe73
|
|
| MD5 |
cbe1454ffcc499784f8c50cfd1507b17
|
|
| BLAKE2b-256 |
d074e5339af11a5f0d94c068e4e0a9d5dcc3a82551f4fd7e7b5bc21a8ba5ed17
|
File details
Details for the file zloop-0.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zloop-0.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 601.4 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e1dfa7592f6221fb958f4becab769577aae8d222987882ad72963c9858d72a5
|
|
| MD5 |
36b1e51b07d5afbaa7140ab9b8bc655a
|
|
| BLAKE2b-256 |
7719a7f09eb952b019d07fc26d40c94eb87b2f061ee3cc42b8d3483f8d2f025f
|
File details
Details for the file zloop-0.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zloop-0.0.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 551.5 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d3e6c51551cff25f9fb558894829f5845d1603e25461782959159524cbed28
|
|
| MD5 |
82ab30732e406329e6dc6125e29448d1
|
|
| BLAKE2b-256 |
5c73ed938dd5e7c2b74c9fba722dac598c6675418d933855dd4ad8ecead5f44f
|
File details
Details for the file zloop-0.0.1-cp314-cp314-macosx_11_0_x86_64.whl.
File metadata
- Download URL: zloop-0.0.1-cp314-cp314-macosx_11_0_x86_64.whl
- Upload date:
- Size: 107.6 kB
- Tags: CPython 3.14, macOS 11.0+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff460d454ef4c00e67ea99385acb48be1c1b1ff2e28fc65e8ac5b4f72223db3d
|
|
| MD5 |
614a91520d8bbdb7dc39596e0b9c25f0
|
|
| BLAKE2b-256 |
e47bf3745a3d4507036c97ca115a93643d70fb94b513ef6c93017590f8b2341c
|
File details
Details for the file zloop-0.0.1-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: zloop-0.0.1-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 109.6 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96463bcd13eae294eab28c4744d75092ab38a339281c4763d602d76d111a662e
|
|
| MD5 |
b3f55e67ff8d6f705e993da92a154e2f
|
|
| BLAKE2b-256 |
fc77da45950ac6cb03c2da21f396a66ac5ed76e127aa6b38585df5c95c85e893
|
File details
Details for the file zloop-0.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zloop-0.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 404.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e370db4bfdda062a9b32749b46dab8bc16cead3cd29189ba6d363b05d71f8e9
|
|
| MD5 |
83c3c8cc47a58c51a84c85db7fc29e6e
|
|
| BLAKE2b-256 |
1433b004c932633240787ea6161f37500f81088cba0409fc65f8825d44cc572e
|
File details
Details for the file zloop-0.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zloop-0.0.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 371.6 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3194f01b6da88d7b066c9298b7565ea778a832f2295c37833b97f1ad885942f2
|
|
| MD5 |
0d5f1c73ed82a66fd889218365da3a58
|
|
| BLAKE2b-256 |
5fb4be387f54861d2c4e79290094ab48740cfc1d7c7f2532ba438545dd02b701
|
File details
Details for the file zloop-0.0.1-cp313-cp313-macosx_11_0_x86_64.whl.
File metadata
- Download URL: zloop-0.0.1-cp313-cp313-macosx_11_0_x86_64.whl
- Upload date:
- Size: 75.1 kB
- Tags: CPython 3.13, macOS 11.0+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a2c10b36e463ee28eb5b483928f8175b1cbba5aa658767a862109f69b66c51e
|
|
| MD5 |
3592c9d77197152efa0716019ef56019
|
|
| BLAKE2b-256 |
c25d3989246aed014a8230ac01c0a923f097a252b9abff7726d9176849a9b2d5
|
File details
Details for the file zloop-0.0.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: zloop-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 77.1 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46e97657f5de5a6e8cffe46bb5d0e7d4d70ced9b08522e40d243452def6cfaf4
|
|
| MD5 |
01a6ab1fc76b81c7e22fd63a615bf315
|
|
| BLAKE2b-256 |
83d2650c8e8edb9372be0cb5bd26cb5cdfce967484e2ce51b352d7d8f5a528e5
|
File details
Details for the file zloop-0.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zloop-0.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 208.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6340a676efb387363cbf2d4463280a980d2d14beeffdb60e9c72c5ee2ef76e4f
|
|
| MD5 |
b3dfc899658933360383d3f5df39da7d
|
|
| BLAKE2b-256 |
84b5aa47adb68c48ec283314326c81e156d7a91d5c211c0d91bbf3621769f108
|
File details
Details for the file zloop-0.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zloop-0.0.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 191.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd5133cfc7934c011447d96720914f5e66009cf60aa6397a3780a77045a9b975
|
|
| MD5 |
9fcc6326348ef990e601512f73062b78
|
|
| BLAKE2b-256 |
ed9407bcaeaf7b5da8725742a5b31cc77c24612f2d56256ac73f00545efaa13e
|
File details
Details for the file zloop-0.0.1-cp312-cp312-macosx_11_0_x86_64.whl.
File metadata
- Download URL: zloop-0.0.1-cp312-cp312-macosx_11_0_x86_64.whl
- Upload date:
- Size: 42.6 kB
- Tags: CPython 3.12, macOS 11.0+ x86-64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5f3c7df0a24e0cf7e800a67f01bc96cb17bcdfd311366d497a4f74379df2efd
|
|
| MD5 |
19a08ffcd1b49dc682370acf51f17338
|
|
| BLAKE2b-256 |
e201b9884ea67c0a3f9e1e7e6fd3eaac5ee9e2dc990e51aad5c83d3034e6b599
|
File details
Details for the file zloop-0.0.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: zloop-0.0.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 44.6 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0617e8054285222226e70fd11752408f1fad58895af74fc155969a1b44d123ab
|
|
| MD5 |
dfa99eb6b39e81019a20042403dd5994
|
|
| BLAKE2b-256 |
0de2b9120e15d62382aa2fd2e74f859cff364c4e9dd99c45bb396b6130f18a05
|