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 has been built, compiled, and verified extensively under Fedora 43-44 on an x86_64 architecture equipped with an Intel(R) Core(TM) Ultra 7 265 processor. Compatibility with other Linux distributions, older kernels, or alternative hardware architectures (e.g. AArch64) has not been verified yet. We welcome feedback and pull requests for other environments!


🔧 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
    

⚡ 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.2-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.2-cp314-cp314t-manylinux_2_36_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.36+ ARM64

talyn-0.8.2-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.2-cp314-cp314-manylinux_2_36_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.36+ ARM64

talyn-0.8.2-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.2-cp313-cp313t-manylinux_2_36_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.36+ ARM64

talyn-0.8.2-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.2-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.2-cp314-cp314t-manylinux_2_36_x86_64.whl.

File metadata

File hashes

Hashes for talyn-0.8.2-cp314-cp314t-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 b692026219bc10ac018646ff102461ee47867a2c40cb60f7e2a159487566a39b
MD5 927ab144693bc134bf76d52b024e5c84
BLAKE2b-256 98a8102e60ad2bcbffc906906438a282ed6d5065bd90c5557a8eaf7ea611a4de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp314-cp314t-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 72a1dfbffe94983ef9030089f5124328665ef267062a46b029e4f46b641877c8
MD5 783493d139ecfeb275b15b73b03b7237
BLAKE2b-256 11d2a8754533f478e48f9e80a31dffd0e953507d6b25f86a2b3d2b00e7aa01c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp314-cp314-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 34e69f8e701467adb9df43d2af217975fb7d89fb72a869c425b761f3c1e9c15f
MD5 5a2928c76dd325ca01fe318174be4be3
BLAKE2b-256 3e519e3d8fae944298d5e0f31c700a36f362f3065390125d5ea520e15c78e7dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp314-cp314-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 d6f6b9a7bca0611c5f36b0bd5eeff03b4d20c7d5e5082462c99f1566fd9282eb
MD5 6dae5f4bc72615145350126a809d9208
BLAKE2b-256 c4ed396a0d4e2ae05d864a4e968ef51aa5bf4956c2f3ef1dc79a29e502228e50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp313-cp313t-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 95abcb077f5ea71e32a03607a7d0fec3306eb88f214ad221e1b2fb73e426b0b3
MD5 d51f8fe2a50a964b5f0185cef292cb20
BLAKE2b-256 d180747297557ad5410a9b089c8f23e9b08eb26d979730c7e55e42d26f99521e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp313-cp313t-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 0a2bdd82372dcbb43cf953a7fb300e4af1355d8f0add0b8de46ae787110cc47c
MD5 bd7333b308f226ae2abf8a1af070979c
BLAKE2b-256 6b12f5cb3fbd208c97ca1e1ff396fb2c158a7bc70228915a86a1f3116421b21d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp313-cp313-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 e54d1ba6ab16871c637b0e68aa9312bba1898b9401e2b33ea43f0a524091ae52
MD5 aa95b92dd3a7957550de5916cd28b894
BLAKE2b-256 6bf30fa0eaf8c437a4d7aa19147a5a38c19d876a500023fc1bfbd829196b0d0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.8.2-cp313-cp313-manylinux_2_36_aarch64.whl
Algorithm Hash digest
SHA256 da73fb27499d8ed1bd303fd2e76f09ae9dde22b9a02baa5dcafcee91bf55a6db
MD5 96719eefe6dca50a46de75045ab9d82c
BLAKE2b-256 2967fff7f7ab31a0abf2ac1351544a94bead2bf8664b8807cff0ddaae30cad4f

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

0.8.5

12 files

0.8.4

8 files

0.8.3

7 files

This release

0.8.2 This release

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