Skip to main content

Talyn: Robust, Stable AsyncIO Event Loop for Python

License Python Compatibility Linux Compatibility Zig Compatibility PyPI Version

Talyn is a robust, exceptionally stable, and realistically fast asyncio event loop drop-in replacement for Python, powered by the asynchronous capabilities of Zig and io_uring.

Talyn prioritizes correctness, complete system safety, and high usability over artificial micro-benchmark superiority. It is fully compatible with CPython's standard single-threaded and free-threaded (GIL-disabled) runtimes.


🚀 Features

  • Realistic Speed: Designed to deliver solid and reliable I/O performance on Linux by leveraging io_uring's native kernel-side asynchronous completion queues.
  • Robust & Crash-Resistant: Meticulously hardened against circular reference memory leaks, stack alignment faults, signal interrupt deadlocks, and use-after-free bugs.
  • Full Asyncio Compatibility: Passes 100% of standard Python asyncio, subprocess, transports, and connection-lifecycle test suites.
  • Modern Packaging: Fully migrated to PEP 517/518 standard declarative pyproject.toml configuration.
  • GIL-Disabled Free-Threading Ready: Fully compatible with python3.13t and python3.14t without memory races.

📜 Requirements

  • Python: >= 3.13 (Tested and verified under CPython 3.13, 3.14, 3.13t (free-threaded), and 3.14t (free-threaded))
  • Linux Kernel: >= 7.0 (Verified on Linux Kernel 7.0.x)
  • Zig Compiler (for source builds): 0.16.0 (Fedora packages)

[!NOTE] Tested Platform Verification: Talyn is primarily developed and tested under Fedora 44 on an x86_64 architecture equipped with an Intel(R) Core(TM) Ultra 7 265 processor. Since v0.8.5 we also build and verify aarch64 and riscv64 wheels on the same x86_64 host: the native extension is cross-compiled by Zig, and the full test suite is executed inside Fedora 44 QEMU VMs (see Linux Development below).


🔧 Installation & Testing

To compile and install Talyn locally on a native Linux machine, run:

pip install -e .

🍎 macOS Development & Testing via Podman (Apple Silicon)

Since Talyn is a Linux-only project leveraging io_uring, development and testing on macOS require running inside a Linux environment.

We provide a frictionless, automated setup using Podman and a Fedora 44 (AARCH64) container:

  1. Install Podman:
    brew install podman
    
  2. Initialize the Podman VM (only needed once):
    podman machine init
    
  3. Run the test suite (the script automatically starts the VM if it's stopped, builds the image, runs the tests with proper permissions, and stops the VM at the end if it started it):
    ./scripts/macos/run_tests.sh
    

You can pass any options supported by test_all.sh (e.g., --verbose or --python=3.13):

./scripts/macos/run_tests.sh --verbose --python=3.13

To force a rebuild of the Fedora testing image:

./scripts/macos/run_tests.sh --rebuild-image

📊 Benchmarking

We also provide a wrapper to run the benchmark suite inside the Fedora container using the optimized ReleaseFast target:

./scripts/macos/benchmark.sh --python=python3.13

You can target a specific benchmark using --bench (note that benchmark names with spaces must be quoted):

./scripts/macos/benchmark.sh --python=python3.13 --bench="task spawn"

The generated comparison plots will be automatically saved to benchmarks/output/.

📦 Building & Publishing Multi-Architecture Wheels

If you are developing on macOS (Apple Silicon) and need to build and publish wheels for both aarch64 and x86_64 architectures to PyPI, you can do so in a single command using Podman's emulation:

  1. Build all wheels: This script builds a native aarch64 container image and an emulated x86_64 container image, runs scripts/build.sh inside both, and collects all 8 wheels (4 Python versions × 2 architectures) in the ./dist/ directory:

    ./scripts/macos/build_all_wheels.sh
    
  2. Publish to PyPI: Upload the built distributions in ./dist/ using twine (pre-configured in your repository):

    ./scripts/publish.sh
    

🖥️ Linux (x86_64) Development: Build, Cross-Compile & Multi-Arch Testing

All of Talyn's development—including aarch64 and riscv64 wheels and full test-suite runs—can be done on an x86_64 (Intel) Linux PC, with no MacBook required:

  • Building: Zig is a native cross-compiler, so foreign-architecture wheels and the extension are produced at full host speed — no QEMU involved.
  • Testing: QEMU user-mode emulation (e.g. podman run --platform linux/arm64) cannot run Talyn, because io_uring_setup returns ENOSYS under user-mode emulation and Talyn requires io_uring with no fallback. Instead, we boot a full-system Fedora 44 VM per architecture, whose real guest kernel passes io_uring syscalls through to the host kernel.

📋 1. Fedora 44 required packages

Install Zig, all four Python interpreters with development headers, and the stdlib test suites:

sudo dnf install zig \
    python3.13 python3.13-devel python3.13-freethreading \
    python3.14 python3.14-devel python3.14-freethreading python3.14-freethreading-devel \
    python3.13-test python3.14-test python3.14-freethreading-test

Bootstrap pip and the test tooling for each interpreter:

for p in python3.13 python3.13t python3.14 python3.14t; do
    $p -m ensurepip --upgrade
    $p -m pip install --user pytest pytest-asyncio
done

For foreign-architecture VM testing (aarch64 / riscv64), additionally:

sudo dnf install qemu-system-aarch64 edk2-aarch64 qemu-system-riscv edk2-riscv64 \
    genisoimage openssh-clients

[!NOTE] python3.13-freethreading-test is not packaged for Fedora 44; the stdlib asyncio modules for the free-threaded 3.13 build are skipped automatically by the test suite.

🏗️ 2. Build all wheels natively (x86_64 + aarch64 + riscv64)

./scripts/linux/build_all_wheels.sh

Uses Zig's native cross-compiler — no QEMU needed. Produces 12 wheels (4 Python variants × 3 architectures) in ./dist/, ready for ./scripts/publish.sh.

🧪 3. Run the test suite natively (x86_64)

./scripts/test_all.sh                  # Debug build
./scripts/test_all.sh --starburst      # ReleaseFast build

🖥️ 4. Test foreign-architecture wheels in VMs

Boots a real Fedora 44 VM per architecture (first run downloads the ~0.5 GB cloud image to ~/.cache/talyn-*-vm/) and runs the full pytest suite against each installed wheel:

./scripts/linux/run_tests.sh                     # aarch64 wheels
./scripts/linux/run_tests.sh --arch=riscv64      # riscv64 wheels
./scripts/linux/run_tests.sh --smoke             # quick import + event-loop smoke test only
./scripts/linux/run_tests.sh --shutdown          # stop the VM after the run

⚡ 5. Run the full test_all.sh suite in VMs (cross-compiled, fast)

test_all.sh normally compiles the extension inside the VM, which is slow under QEMU TCG. Instead, cross-compile the four extension variants natively on the host (the same build flags the wheels use) and run test_all.sh --no-build in the VM:

./scripts/linux/run_test_all.sh --arch=aarch64 --starburst
./scripts/linux/run_test_all.sh --arch=riscv64 --starburst

Under heavy emulation, a stdlib module may exceed its per-module timeout (e.g. test_subprocess on riscv64); raise it with TALYN_STDLIB_TIMEOUT=600 and the memory-safety repro timeout with TALYN_REPRO_TIMEOUT=900.

⏱️ Measured timings

scripts/test_all.sh --starburst (4 Python variants: pytest suite + stdlib asyncio suite):

Environment Total time
x86_64 (native) 8m28s
aarch64 VM, in-VM build 42m33s
riscv64 VM, in-VM build 44m56s
aarch64 VM, cross-built (run_test_all.sh) 17m47s
riscv64 VM, cross-built (run_test_all.sh) 24m48s

All configurations pass the pytest suite; under QEMU TCG the emulated runs are ~5× slower than native, and the cross-built runs cut the in-VM build phase (~2.4× speedup on aarch64). An occasional stdlib-asyncio module may time out under heavy emulation (see note above about TALYN_STDLIB_TIMEOUT).

⚡ Optimization & Target Compilation (For Developers & Power Users)

By default, the pre-built wheels generated by build.sh are compiled targeting a generic x86_64 CPU architecture baseline to ensure 100% universal compatibility across all 64-bit modern x86 Linux processors (e.g., matching standard PyPI manylinux wheel compatibility).

Based on our benchmarks and comprehensive validation—including 100% passing results in the standard asyncio test suite across four distinct Python versions—we publish the official binary packages (wheels) compiled in Starburst mode (Zig built with ReleaseFast) to deliver peak performance out of the box with proven stability.

If you are compiling from source, you can customize the compilation optimize mode and target CPU architecture to unleash maximum performance:

1. Compile and Optimize for your Native CPU (Highly Recommended)

To compile Talyn so that it takes full advantage of your host's exact CPU instructions (such as AVX2, AVX-512, cache alignment, etc.):

# Omit TALYN_CPU so Zig defaults to native CPU optimization
TALYN_OPTIMIZE=ReleaseFast pip install .

2. Configure Compilation Modes

You can control Zig's optimize mode by setting the TALYN_OPTIMIZE environment variable (defaults to Debug for developer convenience):

  • TALYN_OPTIMIZE=Debug (Default): Compiles with heavy runtime assertions and debug symbols.
  • TALYN_OPTIMIZE=ReleaseSafe: Compiles with full optimizations but keeps safety checks (e.g. out-of-bounds, overflows).
  • TALYN_OPTIMIZE=ReleaseFast: Compiles with maximum optimizations (Starburst mode), disabling safety checks for peak execution speed.

3. Target a Specific CPU microarchitecture

You can force Zig to compile for a specific target CPU microarchitecture (like x86_64_v2 or x86_64_v3):

TALYN_OPTIMIZE=ReleaseFast TALYN_CPU=x86_64_v3 pip install .

📦 Usage

Basic Usage

To run a coroutine directly with the Talyn event loop:

import talyn
import asyncio

async def main():
    print("Hello from Talyn!")
    await asyncio.sleep(1)
    print("Goodbye from Talyn!")

# Run using Talyn event loop
talyn.run(main())

Graceful Fallback & Hardening Check

For production configurations, you may want to support fallback options. If Talyn is not installed, or if the host Linux kernel does not meet Talyn's safety baseline (monitored by the HARD-01 Kernel Version Guard which requires kernel >= 6.0), the code will gracefully fall back to uvloop (if available), and finally to standard Python asyncio:

import asyncio

# 1. Try to initialize Talyn (performs HARD-01 kernel version check)
try:
    import talyn
    talyn.install()
except (ImportError, RuntimeError):
    # 2. Fallback to uvloop if Talyn is missing or kernel version is too old
    try:
        import uvloop
        uvloop.install()
    except (ImportError, AttributeError):
        # 3. Fallback to standard Python asyncio (do nothing)
        pass

async def main():
    print("Running with the best available event loop!")

asyncio.run(main())

💝 Historical Credits & Origin

Talyn is spun off from Leviathan, an event loop originally pioneered by Enrique Mora. Enrique Mora's creative spark and vision of merging Zig, io_uring, and asyncio laid the critical foundation and architecture of this project.

As Talyn evolved, the implementation underwent a complete systems-level refactoring to transition from a theoretical prototype to a production-grade, crash-resistant runtime:

  • Eliminated multi-crossing Zig/Python vectorcall overhead by implementing a fused scheduler step trampoline in pure Zig.
  • Redesigned completion handlers into flat, GC-safe ring buffers.
  • Fully audited and resolved all memory-leak reference cycles under concurrent connections.

To honor the project's roots and Enrique's early work:


📖 Project Story

  • Development Journey — The full story: from discovery to challenges, the shift from "ultra-fast" to "realistic fast and stable", and how Talyn was built.
  • Why Talyn? — The personal story and meaning behind the new name.

📄 License

This project is licensed under the MIT License. See LICENSE.md for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

talyn-0.8.5-cp314-cp314t-manylinux_2_36_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.36+ x86-64

talyn-0.8.5-cp314-cp314t-manylinux_2_36_riscv64.whl (2.3 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.36+ riscv64

talyn-0.8.5-cp314-cp314t-manylinux_2_36_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.36+ ARM64

talyn-0.8.5-cp314-cp314-manylinux_2_36_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.36+ x86-64

talyn-0.8.5-cp314-cp314-manylinux_2_36_riscv64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.36+ riscv64

talyn-0.8.5-cp314-cp314-manylinux_2_36_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.36+ ARM64

talyn-0.8.5-cp313-cp313t-manylinux_2_36_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.36+ x86-64

talyn-0.8.5-cp313-cp313t-manylinux_2_36_riscv64.whl (2.3 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.36+ riscv64

talyn-0.8.5-cp313-cp313t-manylinux_2_36_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.36+ ARM64

talyn-0.8.5-cp313-cp313-manylinux_2_36_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.36+ x86-64

talyn-0.8.5-cp313-cp313-manylinux_2_36_riscv64.whl (2.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.36+ riscv64

talyn-0.8.5-cp313-cp313-manylinux_2_36_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.36+ ARM64

File details

Details for the file talyn-0.8.5-cp314-cp314t-manylinux_2_36_x86_64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp314-cp314t-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 d84b9faaa0771086e5a3b4d96a3258fd1070c1cb378a5ca8036a9e657c327b91
MD5 bba5807efd22e01ad72e51d21de838c7
BLAKE2b-256 27f64cb94f82896bf65cf7109345be5b9b516119d761ff40ea0ecadd2188d140

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp314-cp314t-manylinux_2_36_riscv64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp314-cp314t-manylinux_2_36_riscv64.whl
Algorithm Hash digest
SHA256 54ad3afdd163361e6add7e4ea7bb90a6701c5044bf4565005a15db8177e35c4b
MD5 964e50add1beeb5f40d4b10f7b2515a3
BLAKE2b-256 eaa5057e389bae5e0ec887395c5d02be7b4b7a18441080105729d930af3c8861

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp314-cp314t-manylinux_2_36_aarch64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp314-cp314t-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 344164ea12b2cc76ad0ce3736feaa8b88330742ae9690d0958e087476c4fd290
MD5 5363798280fcbe0a978b3381a85d2feb
BLAKE2b-256 1e77dedf35f345f020db6e9338f79c1c8a29bab35abef4c20ed98ae9f4a4b1f6

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp314-cp314-manylinux_2_36_x86_64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp314-cp314-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 bf7b91fef5742d1bc7d0c8143f4c64b14aca6439d34db886d7ac0c1280237a0f
MD5 9e32a4575a697ff344cc0b01d7316bd8
BLAKE2b-256 0fc4626882430ed81c3a144453a5cdf0f344dc5839e35adaf58e395ca24b7e5e

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp314-cp314-manylinux_2_36_riscv64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp314-cp314-manylinux_2_36_riscv64.whl
Algorithm Hash digest
SHA256 d3a1f79de5e5316e50c6768c32051d0b314360a326a4c226db549cf68d759a36
MD5 5c667e3c53fb72db8ac7f3abb5248c38
BLAKE2b-256 ee647f6610b42ed1126bef40d262193a6cfb2b87330ea18dce39a1ac3bf7b273

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp314-cp314-manylinux_2_36_aarch64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp314-cp314-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 8b1dd20a97293f9d497ba7fabffee930df27864ac2e585ab36376750f277aaf2
MD5 30b38d5e5f1ec22eb504b6498eaf218a
BLAKE2b-256 f147d99b62f3380ef057483039794a4aa84b6cec444a52327ef8be84b1c4d8f3

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp313-cp313t-manylinux_2_36_x86_64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp313-cp313t-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 45c12023b7f6097d8d6442702c3e34b63da57491ef90e467a9cb1126a3246023
MD5 988093dacea7ca7311f62362849186c3
BLAKE2b-256 5d36bc6dd34764f8e532a583d03decd2cfb1b4421b6e2f0052643c9b3bd4ccba

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp313-cp313t-manylinux_2_36_riscv64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp313-cp313t-manylinux_2_36_riscv64.whl
Algorithm Hash digest
SHA256 d4487d311d674f76108e2ca3bf73992534f23a56e4979c0c8d9226caf861844a
MD5 026329426f968a6e7556d2e8a77f4bdc
BLAKE2b-256 e5db5e71bc66d52c1e73a080cb08808181b4788d88d85861f6468dbd60f9beae

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp313-cp313t-manylinux_2_36_aarch64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp313-cp313t-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 7da9c8818c0db89fa87cdae94b30f91237923dafecc3609b41f3222005c8503e
MD5 aac013fdad446b8ce915503bde6a1813
BLAKE2b-256 93ada56da2ffdbb19ef8082ac2e1ac0e1b6b9855488a51656d916e2487db3d4d

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp313-cp313-manylinux_2_36_x86_64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp313-cp313-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 d3d84459854ccce1b07b19e7408541925410ace2ece2a4194b016271d0b09c56
MD5 795e31f948d80bf31f038e638930a2aa
BLAKE2b-256 bfd721a5de2e4b257670ba150be730d7ef7454c5bc7101afb64321ac4a0a3709

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp313-cp313-manylinux_2_36_riscv64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp313-cp313-manylinux_2_36_riscv64.whl
Algorithm Hash digest
SHA256 15b7bd5a0598530fc33ac78a80eb7230b2d70525c4ca4c54572fdb5729d6b01b
MD5 973b8d72811fa97c2b62abd95856cb8e
BLAKE2b-256 a3262c19b6af7cbd3f38c8793aa5f82e15a2ce243aa57c3380fd68cb1a12b746

See more details on using hashes here.

File details

Details for the file talyn-0.8.5-cp313-cp313-manylinux_2_36_aarch64.whl.

File metadata

File hashes

Hashes for talyn-0.8.5-cp313-cp313-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 9f9a9bc2e4ebbec8d1d6d0b1eea84a214c9f7ef6e5ddd193b869419b282d34d1
MD5 8788b63c5847438d295fe56525ded934
BLAKE2b-256 8d68539a89a1edead2cb9f6c982c11cc64560aefaf108675865bccd27da7cd5b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.9.6

12 files

0.9.4

12 files

0.9.3

12 files

0.9.2

12 files

0.9.1

12 files

0.9.0

12 files

0.8.8

12 files

0.8.7

12 files

This release

0.8.5 This release

12 files

0.8.4

8 files

0.8.3

7 files

0.8.2

8 files

0.8.1

8 files

0.8.0

8 files

0.7.0

7 files

0.6.4

4 files

0.6.3

4 files

0.6.2

4 files

0.6.1

4 files

0.6.0

4 files

0.5.0

4 files

0.4.0

4 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