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