Converting Existing Scripts
May 30, 2026 | 5 min read
Step 1: Identify Hot Paths
python -m cProfile -s cumulative script.py
Step 2: Extract Pure Functions
Move CPU-intensive logic into standalone functions:
# Before: inline in main
for row in data:
process(row)
# After: extractable
def process_all(data):
for row in data:
process(row)
return results
Step 3: Remove Unsupported Patterns
- Replace
yieldwith list building + return. - Replace
async/awaitwith synchronous equivalents in hot paths. - Move
eval/execto configuration-time.
Step 4: Add Type Hints
def process(data: list[dict]) -> list[dict]:
...
Step 5: Benchmark Before and After
pyvorin proof script.py --runs-per-day 100