Spaces:
Running on Zero
Running on Zero
File size: 1,577 Bytes
95db8cd 149a666 95db8cd 149a666 95db8cd 149a666 95db8cd 149a666 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ---
title: Python → Rust & C++
emoji: ⚡
colorFrom: purple
colorTo: pink
sdk: gradio
sdk_version: 6.23.1
app_file: app.py
pinned: false
short_description: LLM ports Python to Rust or C++, measured and verified
---
# Python → Rust & C++
Give it a Python program. An LLM rewrites it in **Rust or C++**. Both are then
compiled and executed under the same sandbox, so the speedup is **measured, not
estimated** — and the two outputs are compared, because a translation that is
fast but wrong is not a translation.
## Measured results
Max subarray sum, O(n²), n=10 000 × 20 seeds, measured on a laptop:
| Target | Model | Python | Compiled | Speedup | Output |
|---|---|---:|---:|---:|:--:|
| C++ | GPT-5 Nano | 24.739 s | 0.337 s | **73×** | identical ✓ |
| Rust | GPT-5 | 24.518 s | 0.391 s | **63×** | identical ✓ |
| Rust | GPT-5 Nano | 24.590 s | 0.405 s | **61×** | identical ✓ |
Timings on this Space will be slower — it runs on shared CPU. The *ratio* is the
point and stays representative.
## Notes
- **Free to use.** The demo runs on a free-tier model. Frontier models (GPT-5,
Claude, Grok) require your own API key — pasted keys are used for a single
request and never logged, stored, or written to disk.
- **Submitted code is sandboxed.** It runs in a separate process with an
allowlisted environment containing no API keys, a wall-clock timeout, and
CPU, memory, and process-count limits.
- **First load may take ~30 seconds** if the Space has been idle.
Source and full write-up: <https://github.com/Yugjohri/python-to-rust-cpp>
|