Skip to main content

Talyn: A robust, stable, and realistically fast Zig-powered event loop for Python's asyncio.

Project description

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

To compile and install Talyn locally, run:

pip install -e .

⚡ 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).

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=ReleaseSafe 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). Highly recommended for production.
  • TALYN_OPTIMIZE=ReleaseFast: Compiles with maximum optimizations, 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=ReleaseSafe TALYN_CPU=x86_64_v3 pip install .

📦 Basic Usage

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())

💝 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 native C step trampoline.
  • 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.

Project 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.6.0-cp314-cp314t-manylinux_2_36_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.36+ x86-64

talyn-0.6.0-cp314-cp314-manylinux_2_36_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.36+ x86-64

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

Uploaded CPython 3.13tmanylinux: glibc 2.36+ x86-64

talyn-0.6.0-cp313-cp313-manylinux_2_36_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.36+ x86-64

File details

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

File metadata

File hashes

Hashes for talyn-0.6.0-cp314-cp314t-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 c22cef2c9bf03fc0e1d9025a2c0698588935773370c683016b4ef700945c4530
MD5 9960474f320efeaae8f42af978551bde
BLAKE2b-256 d31e6f123044734c0b9320eef1943b0c186bb8bd81e44642ca43b9850955d062

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.6.0-cp314-cp314-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 ead8a241a4181c7e30dd48a90b2ac6a25545299015974e50b0ed0278c4e62529
MD5 59240ca3f50a4f42b3d887e4e881aa5b
BLAKE2b-256 3f87fa4357da145d5c38ed6a1f77b7e1e7a15b1fa1f68f5281e7b9584ccbfa13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.6.0-cp313-cp313t-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 bdabe3792892db75c273a054e8dd6705041f22c5254dd2dfc262474e94d2f898
MD5 fe01779ad7488101771935d5dd06723f
BLAKE2b-256 ac574a5a7f4ca638314b3cc0d360e30b205a6c589c0e1766ad939935e97a0093

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for talyn-0.6.0-cp313-cp313-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 f4a3f30e83e481e6154d8e8830cd4b3a3426b9a9c59b3e0ad3087f11e6c1afb0
MD5 4991f664491dff61addd23766dfc1ed7
BLAKE2b-256 481ad3628c8f6be8325226feba8444a341615739155e45906ae5c22d0414007e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page