Benchmark results
The Typhon repository contains a suite of small benchmark programs. Each program is a single file that is valid Python and valid Typhon, so CPython and Typhon run the same source. This page summarises the published results. They come from one machine and from programs of 10 to 85 lines of code. Larger applications have not been measured.
Method and limits
-
Each program times its own hot section with
time.perf_counter(). Data setup and compilation are excluded, except in the section on one-off scripts. - Every configuration ran five times, and the median is reported.
- Runs on this machine vary by roughly 10 to 30 percent. Windows and Linux figures can be compared only within one table.
- Every tool printed the same result as CPython for every program, on Windows and on Linux.
- NumPy programs ran with default threads and single-threaded, on both sides, and each side is shown in its faster setting. With default threads, OpenBLAS needed 1,024 ms for the 300 x 300 linear algebra program and 31.7 ms single-threaded. This slowdown is a known over-subscription problem on CPUs with performance and efficiency cores.
- PyPy, Cython, mypyc, Numba and CPython's experimental JIT were not measured.
| Machine | Intel Core Ultra 9 285HX laptop (8 performance and 16 efficiency cores, 64 GB RAM) |
|---|---|
| Windows | .NET SDK 11.0.100, CPython 3.15.2, NumPy 2.5.5 with OpenBLAS 0.3.34 |
| Linux | Ubuntu 26.04 on WSL2 on the same machine; Codon 0.20.7 and Pythran 0.19.0 |
Typed pure-Python programs
Typhon turns annotated Python into statically typed code. A float attribute becomes an unboxed
double field, and a call becomes a direct call, while CPython executes bytecode on boxed objects.
The gap is widest for arithmetic on simple types and narrowest where CPython already spends its time in C, as
in hashing, string comparison and sorting. Over the nine programs, the geometric mean speed-up is
11.1x with the JIT and 13.6x with Native AOT.
- Typhon JIT
- Typhon Native AOT
Native AOT is faster than the JIT on six of the nine programs and level on Mandelbrot. The JIT is faster on
N-body and sorted(). The benchmark report gives the JIT's profile-guided optimisation at run time
as the reason.
| Program | CPython | Typhon JIT | Typhon AOT | Speed-up JIT | Speed-up AOT | RAM CPython | RAM JIT | RAM AOT |
|---|---|---|---|---|---|---|---|---|
| N-bodyfloat math on object attributes | 3,024 ms | 40.3 ms | 43.8 ms | 75x | 69x | 12 MB | 21 MB | 9 MB |
| Spectral normnested loops, small function calls | 469 ms | 9.7 ms | 8.6 ms | 48x | 54x | 12 MB | 21 MB | 9 MB |
| Mandelbrottight float loop | 2,067 ms | 51.1 ms | 51.9 ms | 40x | 40x | 12 MB | 20 MB | 9 MB |
| fib(32)recursive calls | 134 ms | 9.0 ms | 4.7 ms | 15x | 29x | 12 MB | 20 MB | 9 MB |
| Binary treesmillions of small objects | 783 ms | 75.3 ms | 55.5 ms | 10x | 14x | 22 MB | 43 MB | 32 MB |
| Fannkuchint lists, swaps, slicing | 324 ms | 39.1 ms | 28.4 ms | 8.3x | 11x | 12 MB | 41 MB | 27 MB |
| Prime sievelist indexing, sum over a generator | 989 ms | 358 ms | 199 ms | 2.8x | 5.0x | 50 MB | 37 MB | 23 MB |
| Word countstring building, dict updates | 413 ms | 161 ms | 140 ms | 2.6x | 3.0x | 12 MB | 41 MB | 27 MB |
| sorted()sorting 1M ints and 300k strings | 353 ms | 182 ms | 218 ms | 1.9x | 1.6x | 88 MB | 61 MB | 54 MB |
Before whole-program type inference existed, the N-body source without annotations fell back to
dynamic and ran 1.5x faster than CPython. With inference, it runs as fast as the annotated
version: 74x and 72x in the same run on battery.
NumPy programs
Typhon does not compile NumPy, whose core is C and Fortran. It runs these programs against Typhon.NumPy, a NumPy-compatible library written in C# for the project. Over the six programs, the result is close to parity: a geometric mean of 1.04x with the JIT and 1.13x with Native AOT. Typhon.NumPy is faster where NumPy pays a per-call overhead in Python. In these runs, NumPy was faster where it calls OpenBLAS and LAPACK.
The matrix multiplication and linear algebra rows predate a rewrite of Typhon.NumPy's dense linear algebra.
On Linux with an Intel Core i7-10700K, a 1000 x 1000 matrix product then ran at 74 to 86 % of OpenBLAS's
speed on one thread and about as fast on all cores, and inv of a 1000 x 1000 matrix went from 1.5 s
to 91 ms, against 63 ms for NumPy. Section 9 of the
benchmark report has the details.
- Typhon JIT
- Typhon Native AOT
| Program | NumPy | Typhon JIT | Typhon AOT | Result, fastest Typhon build | RAM NumPy | RAM JIT | RAM AOT |
|---|---|---|---|---|---|---|---|
| Element loop a[i] | 271 ms | 54.0 ms | n/a (dynamic) | Typhon 5.0x faster | 43 MB | 61 MB | n/a |
| Broadcasting | 268 ms | 95.9 ms | 52.9 ms | Typhon 5.1x faster | 211 MB | 516 MB | 578 MB |
| ufuncs | 1,184 ms | 1,089 ms | 522 ms | Typhon 2.3x faster | 74 MB | 362 MB | 225 MB |
| Reductions | 414 ms | 340 ms | 224 ms | Typhon 1.8x faster | 89 MB | 91 MB | 72 MB |
| Matmul 1000 x 1000 | 17.4 ms | 24.4 ms | 40.3 ms | NumPy 1.4x faster | 64 MB | 89 MB | 56 MB |
| linalg 300 x 300 | 31.7 ms | 325 ms | 159 ms | NumPy 5.0x faster | 37 MB | 37 MB | 16 MB |
Start-up and footprint
The start-up program splits, uppercases and joins a string, and the times run from process start to exit. As a Native AOT executable, the Typhon program was the fastest and leanest of all tools tested on Linux.
| Tool | Windows time | Windows RAM | Linux time | Linux RAM | What is shipped |
|---|---|---|---|---|---|
| CPython | 19.7 ms | 12 MB | 9.2 ms | 12 MB | the .py file and a Python installation |
| Codon | n/a | n/a | 8.3 ms | 10 MB | a small executable and Codon's runtime libraries |
| Typhon JIT | 34.5 ms | 20 MB | 20 ms | 30 MB | a 0.05 MB .dll and the .NET runtime |
| Typhon Native AOT | 21.3 ms | 9 MB | 1.8 ms | 4 MB | one self-contained 1.5 to 1.9 MB executable |
Codon runs on Linux and macOS, so it has no Windows figures.
One-off scripts, compile time included
A script often runs only once, so this comparison times the whole process: python script.py
against typhon run script.ty in its three situations, and against programs built ahead of time.
The first typhon run compiles in its own process. Later runs use the warm compile server, and an
unchanged script comes from the cache. All times are in milliseconds and were measured on Windows on battery.
| Program | CPython | First run | Compile server | Cached | typhon build | Built, per run | build --aot | AOT, per run |
|---|---|---|---|---|---|---|---|---|
| Tiny script (start-up) | 30.0 | 642 | 84.0 | 80.0 | 1,034 | 45.0 | 5,775 | 23.0 |
| fib(32) | 155 | 654 | 88.0 | 83.0 | 1,026 | 72.0 | 5,917 | 34.0 |
| Spectral norm | 536 | 671 | 107 | 111 | 939 | 58.0 | 5,887 | 41.0 |
| Word count | 428 | 935 | 400 | 281 | 996 | 221 | 6,736 | 228 |
| Binary trees | 948 | 719 | 204 | 174 | 955 | 128 | 6,610 | 99.0 |
| Prime sieve | 1,449 | 1,102 | 431 | 431 | 923 | 425 | 6,083 | 251 |
| Mandelbrot | 2,063 | 691 | 167 | 147 | 954 | 116 | 5,613 | 93.0 |
| N-body | 3,283 | 721 | 146 | 126 | 915 | 95.0 | 5,546 | 78.0 |
| N-body without type hints | 3,301 | 670 | 165 | 114 | 947 | 103 | 5,852 | 80.0 |
| NumPy matmul | 169 | 667 | 167 | 140 | 1,128 | 121 | 6,199 | 88.0 |
| NumPy ufuncs | 1,666 | 2,080 | 1,703 | 1,632 | 952 | 1,525 | 6,151 | 710 |
In this table, the first run is already faster than CPython for five programs, for example N-body with 721 ms
against 3,283 ms. With the compile server or the cache, CPython stays faster only for the tiny script and is
level on the two NumPy programs whose time goes into BLAS and ufunc kernels. typhon build takes
about one second, and every built pure-Python benchmark except the tiny start-up script makes up for it after 1 to
13 runs. Native AOT builds take
5.5 to 6.7 seconds.
Plain loops against vectorized NumPy
The same problems written as plain Python loops and as vectorized NumPy code, each run on both runtimes on Windows. With the JIT, plain loops in Typhon run 6 to 38 times faster than the same loops in CPython. They beat vectorized NumPy on three of the six problems, where vectorizing forces extra work: Mandelbrot cannot stop early per point, and pairwise distances and π build large temporary arrays. NumPy stays ahead where one tuned kernel does the whole job, as BLAS does for the dot product and matrix multiplication.
| Problem | CPython loops | CPython + NumPy | Typhon loops, JIT | Typhon loops, AOT | Typhon + NumPy, AOT |
|---|---|---|---|---|---|
| Mandelbrot 400 x 400 | 496 ms | 415 ms | 14.2 ms | 11.4 ms | 234 ms |
| Pairwise distances, 1500 points | 148 ms | 30.3 ms | 3.9 ms | 3.3 ms | 8.1 ms |
| Estimate π, 5M points | 388 ms | 160 ms | 45.0 ms | 43.5 ms | 32.9 ms |
| Moving average, 5M samples | 329 ms | 31.3 ms | 56.0 ms | 56.3 ms | n/a (dynamic) |
| Dot product, 10M floats | 152 ms | 1.4 ms | 6.8 ms | 6.5 ms | n/a (dynamic) |
| Matrix multiply 200 x 200 | 206 ms | 0.4 ms | 12.3 ms | 7.4 ms | 0.7 ms |
Other Python compilers on Linux
The same files were compiled with Codon, which compiles whole programs to native code through LLVM, and with Pythran, which compiles numeric functions to C++. Each tool is compared with CPython on Linux. On the six programs that all four can compile, the geometric means are 13.6x for Pythran, 11.8x for Typhon AOT, 11.6x for Codon and 9.2x for the Typhon JIT. Typhon is at or near the top on float- and object-heavy code. Codon and Pythran lead on integer and list code and on NumPy-style code.
| Program | Codon | Pythran | Typhon JIT | Typhon AOT |
|---|---|---|---|---|
| N-body | 37x | n/a (classes) | 62x | 54x |
| Spectral norm | 39x | 39x | 41x | 28x |
| Mandelbrot | 16x | 26x | 28x | 28x |
| fib(32) | 14x | 25x | 14x | 28x |
| Binary trees | n/a (string annotation) | n/a (classes) | 8.2x | 13x |
| Fannkuch | 9.5x | 15x | 6.6x | 9.3x |
| Prime sieve | 12x | 15x | 2.8x | 5.1x |
| sorted() | 3.9x | n/a (not in a function) | 2.0x | 1.6x |
| Word count | 2.5x | 1.2x | 1.9x | 2.6x |
| N-body without type hints | 29x | n/a (classes) | 1.1 (before inference) | n/a (dynamic) |
| NumPy element loop | 19x | 31x | 4.4x | n/a (dynamic) |
| NumPy broadcasting | 1.1x | 5.1x | 1.4x | 2.4x |
| NumPy ufuncs | 1.5x | 2.3x | 0.8x | 1.9x |
| NumPy matmul 1000 x 1000 | 0.4x | n/a (not in a function) | 0.6x | 0.3x |
The Linux run predates whole-program type inference, so Typhon falls back to dynamic on N-body
without type hints and reaches 1.1x. Codon infers types for the whole program and reaches 29x on the same
source. A new Linux run with inference is one of the roadmap ideas.
Memory
With the JIT, a Typhon process starts about 8 MB higher than CPython because of the .NET runtime. Native AOT removes that floor, with 9 MB against CPython's 12 MB on Windows. Typhon's garbage collector frees memory in batches, so allocation-heavy programs use more RAM with the JIT and with Native AOT. Typed lists are much denser than Python lists, so programs that hold large lists use less memory, for example 175 MB against 468 MB for the dot product. Large temporary NumPy arrays are Typhon's weak spot, with up to five times NumPy's peak.
Sources
All figures on this page come from the Typhon repository at commit 106cf11.
The report also explains each measurement and compares the plugged-in run with the run on battery power.