Skip to Content

Where does PyPy or a JIT-ed build make sense?

Category: Python Fundamentals

Answer

CPython is the safe default. PyPy can be 5-10x faster on long-running pure-Python loops, but libraries with C extensions (numpy, pandas, anything with binary wheels) usually don’t run on PyPy. CPython 3.13 has a JIT in experimental builds. For AI work, optimize the I/O + LLM call first; swap Python implementation last.

Concrete examples from the fca project context

Example 1

PyPy wins on long-running pure-Python loops with no C extension.

Example 2

CPython 3.13 JIT: still experimental; risks subtle numerical differences.

Example 3

For ML apps, most time is in C extensions or LLM network calls. Optimize those first.

Example 4

Profile before you switch interpreter.

Data flow / flow chart

long pure-Python loop -> PyPy 5-10x
  numerical/ML libs -> CPython (binary wheels)
  CPU warmups matter more in practice

Takeaway

Switch Python implementations LAST. Profile and optimize the actual bottleneck first.