best-practices

Avoiding Common Pitfalls

Mistakes that cause deoptimisation, fallback, or poor speedup.

Published May 30, 2026

Pitfall 1: Measuring Cold Compile

The first run includes compilation time. Benchmark warm runs only.

Pitfall 2: I/O Bound Workloads

Network and file I/O are not accelerated by compilation.

Pitfall 3: Too-Fast Functions

Functions under 10ms may show unreliable speedups.

Pitfall 4: Ignoring Fallback

A fallback run is slower than CPython. Always check if fallback occurred.

Pitfall 5: Mutable Default Arguments

def bad(items=[]):  # mutable default
    items.append(1)