How morhadotsan/py2cpp-thesis works
py2cpp converts a project’s Python numerical computation and the library code it exercises into a standalone C++ program. The main workflow is discover executed code, prune it, record test inputs and outputs, translate, verify against Python, then hold out unseen inputs and save an accepted result. The UI and CLI expose this workflow; preparation can create a project target, and experiment and speed tools support thesis runs. Edges follow the README and source-index references; unsampled implementation details are not inferred.
Main entry points: app.py Web UI · verify.py Compile and verify · prepare.py Target preparation · prune.py AST pruning
Components 17
Conversion workflow
- Web UI
py2cpp/app.py - Settings and paths
py2cpp/config.py - Coverage discovery
py2cpp/discover.py - AST pruning
py2cpp/prune.py - Case recording
py2cpp/record.py - Target preparation
py2cpp/prepare.py - Compile and verify
py2cpp/verify.py - Run data
runs - Accepted and fast outputs
results
Code translation
- C++ translation
py2cpp/translate.py - Library source cache
py2cpp/sources.py
Generated runtime
- Generated C++ program
results/kmeans_fit/accepted/prog.cpp - NPY array I/O
py2cpp/npy.hpp
Experiments
- Experiment runner
py2cpp/experiment.py - Speed comparison
py2cpp/speed.py
Other components
- Engineer
- Claude API
Connections 22
- Engineer → Web UI: starts conversion
- Web UI → Coverage discovery: analyse
py2cpp/app.py - Web UI → AST pruning: prune code
py2cpp/app.py - Web UI → Case recording: record cases
py2cpp/app.py - Web UI → Compile and verify: convert and verify
py2cpp/app.py - Web UI → Target preparation: prepare target
py2cpp/app.py - Web UI → Experiment runner: show experiments
py2cpp/app.py - Coverage discovery → AST pruning: measured code
py2cpp/prune.py - AST pruning → Case recording: pruned inputs
- Case recording → Compile and verify: test cases
- AST pruning → Library source cache: resolves library source
py2cpp/prune.py - Compile and verify → C++ translation: requests translation
py2cpp/verify.py - Target preparation → Coverage discovery: checks draft
py2cpp/prepare.py - Target preparation → Case recording: records draft cases
py2cpp/prepare.py - Target preparation → C++ translation: drafts target
py2cpp/prepare.py - C++ translation → Claude API: sends code prompt
- Compile and verify → Claude API: requests repairs
- Compile and verify → Run data: logs attempts
- Compile and verify → Accepted and fast outputs: saves accepted program
- Generated C++ program → NPY array I/O: loads and saves arrays
results/kmeans_fit/accepted/prog.cpp - Experiment runner → Run data: reads recorded runs
- Speed comparison → Accepted and fast outputs: writes speed report