Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Add TurboAPI framework [Python + Zig]#10902

Closed
justrach wants to merge 6 commits intoTechEmpower:masterfrom
justrach:master
Closed

Add TurboAPI framework [Python + Zig]#10902
justrach wants to merge 6 commits intoTechEmpower:masterfrom
justrach:master

Conversation

@justrach
Copy link
Copy Markdown

New Framework: TurboAPI

Language: Python 3.14t (free-threaded, no GIL)
HTTP Core: Zig 0.15 native server (24-thread pool)
Tests: json, plaintext

What is TurboAPI?

TurboAPI is a drop-in FastAPI replacement that moves the entire HTTP layer (TCP, parsing, routing, JSON serialization, CORS) into Zig. Python only runs your business logic.

  • FastAPI-compatible API (@app.get, @app.post, Depends, middleware)
  • 287 tests passing
  • Zero-alloc response pipeline (stack buffers, single write syscall)
  • Response caching (body cached after first Python call, subsequent requests skip Python)
  • Zig-native CORS (pre-rendered headers, 0% overhead)

Test endpoints

Test URL Response
JSON /json {"message":"Hello, World!"}
Plaintext /plaintext Hello, World!

Local verification

================================================================================
Verification Summary
--------------------------------------------------------------------------------
| turboapi
|       json          : PASS
|       plaintext     : PASS
================================================================================

Files

  • frameworks/Python/turboapi/benchmark_config.json
  • frameworks/Python/turboapi/turboapi.dockerfile
  • frameworks/Python/turboapi/app.py
  • frameworks/Python/turboapi/README.md

Docker

Uses uv to install Python 3.14t free-threaded + Zig 0.15 for the native HTTP backend. Builds and runs on both x86_64 and aarch64.

justrach and others added 5 commits March 19, 2026 19:14
Docker builds with Python 3.14t free-threaded (via uv) + Zig 0.15.
Both /json and /plaintext endpoints respond correctly.

Known issue: container exits after ~5s due to Linux Zig thread cleanup
segfault (tracked in justrach/turboAPI CI). Server responds to requests
while alive. Needs investigation before official TFB submission.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New framework: TurboAPI
- Language: Python 3.14t (free-threaded)
- HTTP core: Zig 0.15 native server
- Tests: json, plaintext
- Verified locally: both PASS
@remittor
Copy link
Copy Markdown
Contributor

Great project! I'm looking forward to the results of the tests!

Comment on lines +10 to +11
def json_test():
return {"message": "Hello, World!"}
Copy link
Copy Markdown
Contributor

@joanhey joanhey Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For each request, an object mapping the key message to Hello, World! must be instantiated.

https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#json-serialization

PD: the bench is about serialize a json object, not to send raw text directly, for that is the plaintext bench.

Copy link
Copy Markdown
Contributor

@remittor remittor Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it's not a string that's returned from the function, but a dictionary. The framework internally serializes the dictionary (a collection of objects) into a byte array.
Example:

@app.route()
@service.json
async def json():
return {'message': 'Hello, World!'}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — added TURBO_DISABLE_CACHE=1 to ensure the dict is created and serialized fresh on every request. No caching.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying — yes, it returns a dict that the framework serializes internally. Also disabled response caching to ensure it's fresh per request.


# Bust Docker cache for git clone
ARG CACHEBUST=1
RUN git clone --depth 1 --branch main https://github.com/justrach/turboAPI.git . && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version ??

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justrach
For tests to be repeatable, there is no need to specify the repository HEAD!
By the way, the socketify project also abuses this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned to v1.0.17.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — both repos now pinned to specific tags (turboAPI v1.0.17, dhi v1.2.1).

# Bust Docker cache for git clone
ARG CACHEBUST=1
RUN git clone --depth 1 --branch main https://github.com/justrach/turboAPI.git . && \
git clone --depth 1 https://github.com/justrach/dhi.git /dhi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version ??

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned to v1.2.1.

@joanhey
Copy link
Copy Markdown
Contributor

joanhey commented Mar 20, 2026

Please add yourself to the maintainers in the benchmark_config.json.

So with any change or marked as broken, you will be notified.

Example:

{
"framework": "quarkus",
"maintainers": ["franz1981", "Sanne", "geoand"],
"tests": [
{
"default": {

WORKDIR /turboapi

# Bust Docker cache for git clone
ARG CACHEBUST=1
Copy link
Copy Markdown
Contributor

@joanhey joanhey Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary !!
When you add the version in Git clone.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

- Add maintainers field to benchmark_config.json
- Disable response caching (TURBO_DISABLE_CACHE=1) for TFB compliance
- Remove unnecessary ARG CACHEBUST
- Pin turboAPI to v1.0.17, dhi to v1.2.1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants