Performance¶
This page shows recorded timings. None of the numbers are typed by hand:
when the site is built, the six judge problems are read from
examples/15_algorithms/measurements.json and the collatz table from the README.
scripts/refresh.py re-measures and reports what has drifted past a tolerance,
and --write records it.
Collatz kernel compared with other compilers¶
This is the collatz kernel from the README. It was run on one machine, ten runs each in a fresh process, and the table shows the kernel's wall time (mean ± standard deviation).
Of the PPy rows, ppy build --unsafe is the wrap-semantics artifact. ppy run
keeps Python-integer semantics: overflow is guarded and falls back to arbitrary
precision.
| compiler | kernel | integer semantics |
|---|---|---|
PPy ppy build --unsafe --host-cpu |
28.8 ± 0.5 ms | 64-bit, wraps on overflow (this machine's instruction set) |
C (clang -O3 -march=native) |
30.8 ± 0.7 ms | 64-bit, wraps on overflow |
PPy ppy build --unsafe |
30.8 ± 0.4 ms | 64-bit, wraps on overflow |
Numba @njit |
32.5 ± 0.9 ms | 64-bit, wraps on overflow |
C (clang -O3) |
32.8 ± 0.5 ms | 64-bit, wraps on overflow |
PPy ppy run |
41.7 ± 1.8 ms | Python ints: guarded, falls back to arbitrary precision |
C (gcc -O3) |
41.9 ± 0.9 ms | 64-bit, wraps on overflow |
Codon -release |
42.1 ± 12.1 ms | 64-bit, wraps on overflow |
| PyPy 3.11 | 52.8 ± 0.5 ms | Python ints |
Cython (cdef long long) |
61.6 ± 0.8 ms | 64-bit, wraps on overflow |
| mypyc | 71.6 ± 1.4 ms | Python ints |
| Nuitka | 714.7 ± 12.8 ms | Python ints, no type specialization |
| CPython 3.14 | 1068.8 ± 5.5 ms | Python ints |
Six judge problems, whole process¶
These are wall times of the whole process, including input reading and interpreter startup. Nothing inside the programs is instrumented. Each problem reads its input from standard input.
| problem | CPython | ppy run |
ppy build --unsafe |
--standalone |
C (gcc -O3) |
C (clang -O3) |
|---|---|---|---|---|---|---|
N-Queens 15a_nqueens |
152.8 ± 14.0 ms | 120.4 ± 165.7 ms | 42.8 ± 2.0 ms | 5.6 ± 0.2 ms | 4.9 ± 0.1 ms | 5.5 ± 0.2 ms |
Shortest paths 15b_dijkstra |
4995.8 ± 52.4 ms | 3739.9 ± 288.7 ms | 4535.9 ± 75.2 ms | 136.2 ± 4.2 ms | 147.3 ± 3.2 ms | 137.8 ± 3.5 ms |
Substring search 15c_kmp |
306.4 ± 17.6 ms | 137.8 ± 177.4 ms | 54.7 ± 0.7 ms | — | 9.9 ± 0.2 ms | 9.5 ± 0.3 ms |
Range sums 15d_segment_tree |
1662.9 ± 30.6 ms | 1315.3 ± 212.5 ms | 1485.8 ± 7.9 ms | 31.1 ± 1.0 ms | 51.3 ± 0.8 ms | 51.5 ± 1.3 ms |
Longest increasing subsequence 15e_lis |
549.5 ± 15.1 ms | 194.8 ± 172.9 ms | 110.5 ± 1.4 ms | 43.6 ± 0.5 ms | 58.1 ± 0.8 ms | 55.5 ± 0.7 ms |
Counting inversions 15f_input |
640.2 ± 21.5 ms | 183.1 ± 181.4 ms | 100.4 ± 0.9 ms | 39.5 ± 1.7 ms | 46.4 ± 1.0 ms | 46.9 ± 1.5 ms |
Recorded on Intel(R) Core(TM) Ultra 9 386H, 16 cores, CPython 3.14.5, Linux-6.6.114.1-microsoft-standard-WSL2-x86_64-with-glibc2.39, at 2026-10-28T01:21:41.
The ppy run column includes the first run's build into the cache. That is
why its deviation is wide. From the second run on, it is the launcher alone.
--standalone is a native executable with no interpreter inside.
ppy run against python¶
ppy run should never be slower than python. Each program below was run
5 times by each command, one process at a time,
and the table shows the median wall time of the whole process in seconds. The
cold column starts from an empty project cache, so it includes analysis,
lowering, and compilation; every later run is the warm one.
A warm run counts as no slower when it is within 5% of python, or 30 ms,
whichever is more: two runs of the same python command differ by that much.
The programs named micro_ are in the script; they call a native candidate
from Python many times, where the crossing matters most. Examples that start a
device runtime (a CUDA context, XLA's client) are left out: their warm time is
that start, which python running the CPU reference never pays. So are the
examples that need a library the default environment (uv sync) does not
install, such as PyTorch, JAX, or pandas: their time is mostly the library's.
A cold run spends its time in four places: importing the compiler, checking and
lowering the program, LLVM optimizing the whole program into one object, and the
C compiler linking that object into a library. The runtimes a program links (the
collections, the async loop) are compiled once per machine and compiler into the
user cache and reused, so a cold run only links them. LLVM IR is emitted once, for
the linked program; a module's own LLVM IR is emitted only when something reads
it, such as ppy inspect --ir.
| program | python |
ppy run, cold |
ppy run, warm |
|---|---|---|---|
01_basics/basics.ppy |
0.035 | 0.522 | 0.051 |
02_arbitrary_precision/arbitrary_precision.ppy |
0.036 | 0.573 | 0.051 |
03_effects_and_contracts/effects.ppy |
0.039 | 0.561 | 0.048 |
04_classes/classes.ppy |
0.041 | 0.516 | 0.039 |
06_pydantic/pydantic_models.ppy |
0.111 | 0.439 | 0.109 |
08_native_data/native_data.ppy |
0.037 | 0.549 | 0.048 |
10_narrowing/narrowing.ppy |
0.037 | 0.534 | 0.044 |
11_numerics/numerics.ppy |
0.034 | 0.518 | 0.045 |
12_buffers_and_jit/buffers_and_jit.ppy |
3.478 | 0.800 | 0.711 |
13_value_classes/value_classes.ppy |
0.174 | 0.590 | 0.072 |
14_tuples/tuples.ppy |
0.041 | 0.517 | 0.048 |
15_algorithms/algorithms.ppy |
4.038 | 1.097 | 0.316 |
16_dynamic/dynamic.ppy |
0.037 | 0.510 | 0.051 |
17_containers/containers.ppy |
0.039 | 0.529 | 0.048 |
18_errors/errors.ppy |
0.040 | 0.512 | 0.045 |
19_strings/strings.ppy |
0.037 | 0.562 | 0.049 |
20_inventory/inventory.ppy |
0.037 | 0.510 | 0.044 |
23_inference/pipeline.ppy |
0.039 | 0.592 | 0.051 |
23_inference/shapes.ppy |
0.039 | 0.519 | 0.047 |
23_inference/stats.ppy |
0.036 | 0.534 | 0.047 |
24_interop/geometry.ppy |
0.039 | 0.449 | 0.045 |
28_threads/threads.ppy |
10.888 | 0.773 | 0.328 |
30_migrate/legacy.ppy |
0.039 | 0.347 | 0.042 |
32_native_memory/native_memory.ppy |
0.051 | 0.513 | 0.060 |
33_simd_and_cpu/lanes.ppy |
0.037 | 0.531 | 0.043 |
34_atomics_and_threads/counters.ppy |
0.048 | 0.530 | 0.052 |
35_parallel_range/ranges.ppy |
0.095 | 0.714 | 0.086 |
37_aio/echo.ppy |
0.077 | 0.526 | 0.065 |
40_generics/generic.ppy |
0.015 | 0.514 | 0.035 |
42_toolbox/toolbox.ppy |
0.011 | 0.495 | 0.032 |
43_regex/patterns.ppy |
0.144 | 0.704 | 0.083 |
47_collections/graphs.ppy |
5.896 | 1.042 | 0.374 |
48_strings/text.ppy |
2.084 | 1.291 | 0.594 |
49_inheritance/shapes.ppy |
5.235 | 3.867 | 2.805 |
50_errors_and_generators/ledger.ppy |
2.289 | 1.025 | 0.333 |
51_clinic/clinic.ppy |
3.020 | 1.829 | 1.205 |
52_unannotated/numbers.ppy |
7.754 | 1.080 | 0.529 |
53_caches_and_counters/words.ppy |
1.653 | 1.592 | 0.786 |
54_objects_and_grids/world.ppy |
2.471 | 1.127 | 0.278 |
55_linked_structures/trees.ppy |
0.748 | 1.395 | 0.393 |
56_options_and_doctests/puzzles.ppy |
1.327 | 1.140 | 0.515 |
15_algorithms/15a_nqueens/nqueens.ppy |
0.168 | 0.527 | 0.061 |
15_algorithms/15b_dijkstra/dijkstra.ppy |
2.187 | 1.234 | 0.494 |
15_algorithms/15c_kmp/kmp.ppy |
0.541 | 0.746 | 0.256 |
15_algorithms/15d_segment_tree/segment_tree.ppy |
0.695 | 0.778 | 0.186 |
15_algorithms/15e_lis/lis.ppy |
0.667 | 0.643 | 0.180 |
15_algorithms/15f_input/inversions.ppy |
0.816 | 0.627 | 0.130 |
26_project/src/app.ppy |
0.218 | 0.523 | 0.049 |
micro_scalar_calls |
0.041 | 0.482 | 0.036 |
micro_collection_peek |
0.043 | 0.482 | 0.043 |
micro_collection_sum |
0.274 | 0.634 | 0.205 |
micro_short_strings |
0.045 | 0.744 | 0.052 |
micro_long_string |
0.070 | 0.619 | 0.051 |
micro_fill |
0.116 | 0.491 | 0.063 |
micro_words |
0.158 | 0.670 | 0.161 |
Recorded on x86_64, 16 cores, CPython 3.14.5, Linux-6.6.114.1-microsoft-standard-WSL2-x86_64-with-glibc2.39, at 2026-10-05.