← all repositories
alxschwrz/codex_py2cpp

When you forget C++ but still want that 10x speedup

A thin wrapper around OpenAI Codex that prompts an LLM to rewrite your Python as C++, then tries to compile the result.

codex_py2cpp
Velocity · 7d
+0.3
★ / day
Trend
steady
star history

What it does

Feed it a .py file and it builds a prompt for OpenAI Codex asking for a C++ translation. If the returned code compiles with g++, you get a .cpp source and a .exe binary. The README shows a toy example: a two-argument add_something function with some cout strings.

The interesting bit

The whole “compiler” is really just prompt engineering plus subprocess.call(g++). The actual heavy lifting—semantic analysis, type inference, memory management decisions—is delegated to a black-box LLM. It’s a neat demonstration of how far you can get with zero static analysis and a prayer.

Key highlights

  • Single-file converter: python2cppconverter.py does the prompt construction and compilation check
  • Requires private Codex API access (not the public ChatGPT API)
  • Successful compilations are cached as .cpp + .exe; failures are silently discarded
  • Includes a time comparison workflow to check if you actually gained speed
  • Explicitly marked work-in-progress by the author

Caveats

  • Author warns: “does not produce robust code conversions”
  • No test suite, no verification that outputs match beyond manual diff
  • Codex API access is gated and may change or disappear

Verdict

Worth a look if you’re experimenting with LLM code generation or need a classroom demo of “what if we just asked an AI to transpile?” Anyone shipping production code should probably learn C++ the old-fashioned way—or reach for Cython, mypyc, or Rust bindings instead.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.