Python Performance: When CPython Is Enough

Python is ‘slow’ in benchmarks; rarely the bottleneck in production. Optimization order matters.

Where Python is slow

Python's reputation for slowness is mostly wrong. The language is slow per CPU instruction, but most production bottlenecks are not CPU at all.

Four-tier optimization

When Cython/Rust

When profiling proves a hot Python loop is the bottleneck, native extensions are the answer. The order matters: profile, then optimise, then port.

PyPy niche

PyPy is a JIT-compiled CPython-compatible runtime. It wins on specific workloads; check whether yours is one before switching.

Antipatterns

What to do this week

Three moves. (1) Apply this pattern to your slowest production endpoint. (2) Measure p99 before/after. (3) Document the win and ship the runbook so the team can reproduce.