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 a hand-written kqueue/epoll
reactor in Zig 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, HTTPX - 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. Faster than uvloop on the workloads measured so far - scheduling,
timers, and small/medium-message socket throughput (e.g.
call_soon+46%, 1 KiB echo +16% on CPython 3.14 / macOS arm64).create_futureties, because all three loops reuse CPython's C-accelerated_asyncio.Future.
Benchmarks
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 - macOS arm64, CPython 3.14, 3
workers, best of 3:
| Message | Server mode | asyncio | uvloop | zloop | zloop vs uvloop |
|---|---|---|---|---|---|
| 1 KiB | proto | 113k | 113k | 121k | +7% |
| 1 KiB | buffered | 115k | 115k | 123k | +7% |
| 1 KiB | streams | 83k | 90k | 103k | +14% |
| 10 KiB | proto | 105k | 110k | 113k | +3% |
| 10 KiB | buffered | 105k | 105k | 124k | +18% |
| 10 KiB | streams | 81k | 86k | 95k | +11% |
For the 1-10 KiB messages common in HTTP, WebSocket frames, and RPC, zloop leads uvloop in every cell. The 100 KiB row is omitted: at that size the test measures loopback bandwidth, not the loop, and all three swing wildly run-to-run.
Reproduce it with scripts/bench (or bash bench_uvloop/run_matrix.sh for the
full matrix); the Benchmark CI workflow runs it on Linux and posts the table
to the run summary.
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.0.tar.gz.
File metadata
- Download URL: zloop-0.0.0.tar.gz
- Upload date:
- Size: 45.5 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 |
6ceaaba3a2c2b717455d43359a0de0938d6d750db55662fa9c557fe65c9f576e
|
|
| MD5 |
6eaf9162861af70d0ca57d8b120a5730
|
|
| BLAKE2b-256 |
2265a3c66f0be4715431f02c3fb3daf0f88a57e2343e81939e8cbe9d3f2dc7b6
|
File details
Details for the file zloop-0.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zloop-0.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 389.5 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 |
b9332a8bef591572264c38cb62b3ed2316a66d7c10571e350bc8dae8f679abfd
|
|
| MD5 |
99f85103206d76296ec985c89fef5648
|
|
| BLAKE2b-256 |
ac0f715c7299e5b3e68e994e41f3e6f1ebb0f09edc1e8a16b1f3addbf0c62806
|
File details
Details for the file zloop-0.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zloop-0.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 365.0 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 |
5e55529194002f7d8372f9bab5d8de4d6a0abef0241d692cca028c3d7345e248
|
|
| MD5 |
f7026dae184ad5f98ad9c5834161bffe
|
|
| BLAKE2b-256 |
b1b5dfa3df62edaa15c931dcb10e0d3917d63ac21f471469d73db551c3a2ac9c
|
File details
Details for the file zloop-0.0.0-cp314-cp314-macosx_11_0_x86_64.whl.
File metadata
- Download URL: zloop-0.0.0-cp314-cp314-macosx_11_0_x86_64.whl
- Upload date:
- Size: 104.8 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 |
67b70e33046faf4db15de9bf66447c4ffebb0d45b2c8fa75fa27169572edd4bc
|
|
| MD5 |
783af2aeb2baef9aa29249382ee2471d
|
|
| BLAKE2b-256 |
8db54ae4983d7fa7a6a734e3e5dd3b30143162a6f4e8007be2488cc0563d8b40
|
File details
Details for the file zloop-0.0.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: zloop-0.0.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 107.0 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 |
7cf015ddf6b2ba8e15d08643756f00e9f0573c83e1b10de39c68413f0c6ac448
|
|
| MD5 |
71ea6dd019ee527226ad2c22a0d780a0
|
|
| BLAKE2b-256 |
7b2968a511a7f4294f7ad91a96b19b90f164cd06ebf414ff32b929021a660d29
|
File details
Details for the file zloop-0.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zloop-0.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 263.4 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 |
a841ef3cb108f298745b56bf9c96d257cb4ddb5ca5dafc926073489f89c9ad68
|
|
| MD5 |
560031d213ae6d470b5acefc2ff2e9aa
|
|
| BLAKE2b-256 |
d50431c293f6d03cb157f386303a1469aa463e3ed8216f1d509f571bdd3d1148
|
File details
Details for the file zloop-0.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zloop-0.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 247.1 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 |
e24c89e2df92cfd0f71c423adbc0bf506ab65ce7f21459a8362c90dcb5f1e183
|
|
| MD5 |
6f0a3457201bad6df7776f654ff26373
|
|
| BLAKE2b-256 |
532915ccb637b4f7b10ad3a9956b6e92043e918c0b4c86a5a1f40577009534a6
|
File details
Details for the file zloop-0.0.0-cp313-cp313-macosx_11_0_x86_64.whl.
File metadata
- Download URL: zloop-0.0.0-cp313-cp313-macosx_11_0_x86_64.whl
- Upload date:
- Size: 72.9 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 |
1716ac4b21002fd0a86d89bd146e7d66dfeebe548c5e3ce355e75b626b776c94
|
|
| MD5 |
c07b02cfd9e0d6c233fdf0c99e7518fd
|
|
| BLAKE2b-256 |
96e78a6d02f85dba6a1658034bcc127a6c0878c53017dfd47e05d5e9ac258318
|
File details
Details for the file zloop-0.0.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: zloop-0.0.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 75.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 |
1855a08ae4ff9dfa9250621efa708d723dde04d6d7e573b3816d54b272db83d8
|
|
| MD5 |
9d9ba938aebe25248015f02393482d4a
|
|
| BLAKE2b-256 |
eb77e25b892e747c3bfea6edaa33640ebb97e8be028cee2915335fc1d7a3b9df
|
File details
Details for the file zloop-0.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: zloop-0.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 137.4 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 |
e3d4347395ca23c52bd9891b2762459bd145bc24a8a63f8aaf1bf67ee3740747
|
|
| MD5 |
5bfa4966c550ec5393a902ec0dd6b5d1
|
|
| BLAKE2b-256 |
4803bb24b6dea8600f8c5052b23e04800e6c86affd798d74f007bb8805c3044a
|
File details
Details for the file zloop-0.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: zloop-0.0.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 129.3 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 |
0553c14b59fcf9ca8152c16ffa7b97c054b8edb08adc49fdd009865d2edffca4
|
|
| MD5 |
8dbaaed8eb85137c377e64fc9186e239
|
|
| BLAKE2b-256 |
4b3ca9370109e5244f6f409fe49c027de109dbe5154a06cddf4736b534e8db63
|
File details
Details for the file zloop-0.0.0-cp312-cp312-macosx_11_0_x86_64.whl.
File metadata
- Download URL: zloop-0.0.0-cp312-cp312-macosx_11_0_x86_64.whl
- Upload date:
- Size: 41.1 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 |
9f55d32ec4ede4f2ef09cd7e806e7472914c2de973ee74f5219cd4c5eb63f4de
|
|
| MD5 |
7e5314c91b0279f892635d5d3a5bfb05
|
|
| BLAKE2b-256 |
3610ecd81d4e8ef211c84be4b8f82ff5b342718dd4ecab4887cc25d76c088a15
|
File details
Details for the file zloop-0.0.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: zloop-0.0.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 43.3 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 |
7f5c984f1704a8eb35d244b9d511370388443e0f7df1ecf665f8f16c69e57a5d
|
|
| MD5 |
871fe8be94c2dfa380183c884bb40aa6
|
|
| BLAKE2b-256 |
1f7d943bb64bab30a35bd87b6cbad963ab78e4c2a80d74540cab2aec5e266a56
|