guides

Converting Existing Scripts

Practical steps to refactor scripts for maximum Pyvorin compatibility.

Published May 30, 2026

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 yield with list building + return.
  • Replace async/await with synchronous equivalents in hot paths.
  • Move eval/exec to 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