Zig VS Python benchmarks

Current benchmark data was generated on Mon Jun 23 2025, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][4 cores] AMD EPYC 7763 64-Core Processor (Model 1)

* -m in a file name stands for multi-threading or multi-processing

* -i in a file name stands for direct intrinsics usage. (Usage of simd intrinsics via libraries is not counted)

* -ffi in a file name stands for non-stdlib FFI usage

* (You may find time < time(user) + time(sys) for some non-parallelized programs, the overhead is from GC or JIT compiler, which are allowed to take advantage of multi-cores as that's more close to real-world scenarios.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1191ms 15ms 96.3MB 1123ms 53ms pypy 3.10.16
zig 1.zig 1880ms 29ms 49.0MB 1853ms 13ms zig 0.14.1
python 1.py timeout 0.0ms 41.0MB 4973ms 17ms cpython 3.13.5
python 1.py timeout 0.0ms 40.5MB 4750ms 230ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 101ms 1.2ms 68.6MB 67ms 20ms pypy 3.10.16
zig 1.zig 152ms 0.9ms 7.0MB 140ms 0ms zig 0.14.1
python 1.py 476ms 3.1ms 11.9MB 453ms 10ms pyston 3.8.12
python 1.py 734ms 12ms 13.0MB 723ms 0ms cpython 3.13.5

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 254ms 3.5ms 83.4MB 217ms 20ms pypy 3.10.16
python 1.py 362ms 1.9ms 12.6MB 343ms 3ms cpython 3.13.5
python 1.py 2004ms 4.0ms 9.6MB 1990ms 0ms pyston 3.8.12
zig 1.zig 2272ms 16ms 2.5MB 2240ms 17ms zig 0.14.1

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 102ms 1.5ms 63.6MB 77ms 10ms pypy 3.10.16
python 1.py 112ms 2.1ms 12.3MB 100ms 0ms cpython 3.13.5
python 1.py 352ms 1.3ms 8.8MB 340ms 0ms pyston 3.8.12
zig 1.zig 381ms 1.4ms 1.9MB 367ms 0ms zig 0.14.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 637ms 2.3ms 1.4MB 2397ms 0ms zig 0.14.1
zig 3-i.zig 1766ms 1.5ms 1.0MB 1760ms 0ms zig 0.14.1
zig 1.zig 2723ms 11ms 1.0MB 2713ms 0ms zig 0.14.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 61ms 0.4ms 1.4MB 200ms 0ms zig 0.14.1
zig 3-i.zig 147ms 0.1ms 1.0MB 140ms 0ms zig 0.14.1
zig 1.zig 229ms 0.5ms 1.0MB 220ms 0ms zig 0.14.1

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 88ms 1.0ms 1.0MB 80ms 0ms zig 0.14.1
python 1.py 1867ms 5.3ms 88.9MB 1820ms 33ms pypy 3.10.16
python 5-m.py 2287ms 10ms 65.6MB 3470ms 880ms pypy 3.10.16
python 5-m.py 2582ms 230ms 12.5MB 3513ms 1153ms pyston 3.8.12
python 1.py 3033ms 32ms 8.1MB 3020ms 0ms pyston 3.8.12
python 5-m.py 3368ms 22ms 13.9MB 4457ms 910ms cpython 3.13.5
python 1.py 4740ms 91ms 9.0MB 4727ms 0ms cpython 3.13.5

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 10ms 0.0ms 1.0MB 0ms 0ms zig 0.14.1
python 1.py 255ms 1.5ms 63.4MB 223ms 17ms pypy 3.10.16
python 5-m.py 310ms 1.8ms 12.5MB 400ms 140ms pyston 3.8.12
python 1.py 314ms 0.6ms 8.1MB 300ms 0ms pyston 3.8.12
python 5-m.py 402ms 9.2ms 13.9MB 490ms 130ms cpython 3.13.5
python 5-m.py 450ms 6.4ms 65.6MB 747ms 310ms pypy 3.10.16
python 1.py 494ms 21ms 8.9MB 483ms 0ms cpython 3.13.5

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 0.9ms 0.0ms 1.1MB 0ms 0ms zig 0.14.1
python 1.py 11ms 0.5ms 7.6MB 0ms 0ms pyston 3.8.12
python 1.py 14ms 1.1ms 8.9MB 0ms 0ms cpython 3.13.5
python 1.py 29ms 1.3ms 51.7MB 10ms 10ms pypy 3.10.16

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1-m.zig 348ms 15ms 67.1MB 953ms 30ms zig 0.14.1
zig 1.zig 509ms 2.9ms 27.4MB 487ms 10ms zig 0.14.1
python 3-m.py 2416ms 17ms 136.5MB 8193ms 343ms pypy 3.10.16
python 3-m.py 3230ms 12ms 34.0MB 12220ms 127ms pyston 3.8.12
python 3.py timeout 0.0ms 35.8MB 90ms 17ms cpython 3.13.5

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 67ms 1.9ms 15.4MB 50ms 7ms zig 0.14.1
zig 1-m.zig 70ms 2.7ms 54.3MB 147ms 33ms zig 0.14.1
python 3-m.py 385ms 3.1ms 75.7MB 973ms 157ms pypy 3.10.16
python 3-m.py 406ms 10ms 14.4MB 1347ms 73ms pyston 3.8.12
python 3-m.py 660ms 2.8ms 15.2MB 2327ms 63ms cpython 3.13.5

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 35ms 2.2ms 2.8MB 27ms 0ms zig 0.14.1
python 2.py 148ms 3.7ms 58.4MB 123ms 10ms pypy 3.10.16
python 1.py 182ms 4.5ms 59.4MB 160ms 10ms pypy 3.10.16
python 1.py 742ms 13ms 8.9MB 730ms 0ms pyston 3.8.12
python 2.py 861ms 17ms 8.5MB 850ms 0ms pyston 3.8.12
python 1.py 1135ms 8.0ms 9.5MB 1120ms 0ms cpython 3.13.5
python 2.py 1359ms 9.5ms 9.4MB 1347ms 0ms cpython 3.13.5

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 92ms 1.2ms 2.8MB 80ms 0ms zig 0.14.1
python 2.py 340ms 3.5ms 59.4MB 317ms 10ms pypy 3.10.16
python 1.py 378ms 4.8ms 60.3MB 353ms 13ms pypy 3.10.16
python 1.py 2158ms 21ms 8.9MB 2147ms 0ms pyston 3.8.12
python 2.py 2527ms 78ms 8.5MB 2513ms 0ms pyston 3.8.12
python 1.py 3383ms 12ms 9.5MB 3370ms 0ms cpython 3.13.5
python 2.py 3989ms 100ms 9.3MB 3973ms 0ms cpython 3.13.5

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 16ms 1.4ms 1.3MB 10ms 0ms zig 0.14.1
python 2.py 107ms 0.7ms 58.2MB 80ms 13ms pypy 3.10.16
python 1.py 121ms 2.3ms 58.8MB 100ms 10ms pypy 3.10.16
python 1.py 356ms 7.7ms 8.5MB 343ms 0ms pyston 3.8.12
python 2.py 388ms 3.7ms 8.1MB 377ms 0ms pyston 3.8.12
python 1.py 542ms 5.2ms 9.4MB 530ms 0ms cpython 3.13.5
python 2.py 648ms 0.8ms 8.9MB 637ms 0ms cpython 3.13.5

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 248ms 0.9ms 4.1MB 240ms 0ms zig 0.14.1

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 13ms 0.1ms 1.1MB 10ms 0ms zig 0.14.1

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 913ms 47ms 41.0MB 887ms 10ms zig 0.14.1
python 1.py 2233ms 15ms 202.7MB 2127ms 97ms pypy 3.10.16
python 1.py timeout 0.0ms 94.1MB 4957ms 33ms cpython 3.13.5
python 1.py timeout 0.0ms 130.4MB 4937ms 50ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 178ms 4.2ms 11.0MB 163ms 0ms zig 0.14.1
python 1.py 385ms 7.0ms 104.8MB 327ms 43ms pypy 3.10.16
python 1.py 3165ms 60ms 37.3MB 3140ms 13ms cpython 3.13.5
python 1.py timeout 0.0ms 48.9MB 4963ms 23ms pyston 3.8.12

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 3.zig 198ms 0.3ms 1.0MB 190ms 0ms zig 0.14.1
zig 2.zig 281ms 1.9ms 1.0MB 270ms 0ms zig 0.14.1
zig 1.zig 317ms 0.8ms 1.1MB 310ms 0ms zig 0.14.1
python 2.py 1361ms 5.0ms 57.9MB 1333ms 10ms pypy 3.10.16
python 1.py 2654ms 8.4ms 58.4MB 2627ms 10ms pypy 3.10.16
python 1.py timeout 0.0ms 9.0MB 4990ms 0ms cpython 3.13.5
python 2.py timeout 0.0ms 9.0MB 4990ms 0ms cpython 3.13.5
python 1.py timeout 0.0ms 8.3MB 4990ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 8.1MB 4990ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 3.zig 22ms 0.6ms 1.3MB 13ms 0ms zig 0.14.1
zig 2.zig 30ms 0.1ms 1.0MB 20ms 0ms zig 0.14.1
zig 1.zig 33ms 0.1ms 1.1MB 27ms 0ms zig 0.14.1
python 2.py 180ms 2.2ms 58.2MB 157ms 10ms pypy 3.10.16
python 1.py 306ms 6.8ms 57.2MB 283ms 10ms pypy 3.10.16
python 1.py 943ms 6.5ms 8.3MB 933ms 0ms pyston 3.8.12
python 2.py 1324ms 11ms 8.1MB 1313ms 0ms pyston 3.8.12
python 1.py 2929ms 30ms 9.0MB 2917ms 0ms cpython 3.13.5
python 2.py 2959ms 13ms 9.0MB 2947ms 0ms cpython 3.13.5

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 291ms 9.9ms 40.2MB 273ms 0ms zig 0.14.1
zig 2.zig 325ms 2.3ms 6.0MB 317ms 0ms zig 0.14.1
python 1.py 2598ms 50ms 369.6MB 2527ms 57ms pypy 3.10.16
python 2.py 3047ms 54ms 632.9MB 2860ms 173ms pyston 3.8.12
python 1.py 4792ms 40ms 320.4MB 4733ms 43ms pyston 3.8.12
python 1.py timeout 0.0ms 321.4MB 4960ms 20ms cpython 3.13.5
python 2.py timeout 0.0ms 633.8MB 4817ms 173ms cpython 3.13.5
python 2.py timeout 0.0ms 960.0MB 4707ms 283ms pypy 3.10.16

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 51ms 0.2ms 10.9MB 40ms 0ms zig 0.14.1
zig 2.zig 80ms 0.7ms 2.3MB 70ms 0ms zig 0.14.1
python 1.py 555ms 7.1ms 135.3MB 520ms 20ms pypy 3.10.16
python 2.py 736ms 10.0ms 164.3MB 693ms 30ms pyston 3.8.12
python 1.py 1099ms 37ms 86.0MB 1077ms 10ms pyston 3.8.12
python 2.py 1419ms 19ms 165.1MB 1373ms 33ms cpython 3.13.5
python 2.py 1579ms 52ms 290.2MB 1487ms 77ms pypy 3.10.16
python 1.py 2896ms 26ms 87.0MB 2870ms 10ms cpython 3.13.5

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 1919ms 1.6ms 8.9MB 1877ms 27ms pyston 3.8.12
python 4.py 1963ms 11ms 9.5MB 1907ms 40ms cpython 3.13.5
python 4.py 2195ms 8.6ms 89.5MB 2153ms 27ms pypy 3.10.16
zig 1.zig 2452ms 13ms 2.2MB 2420ms 13ms zig 0.14.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 451ms 1.8ms 8.6MB 440ms 0ms pyston 3.8.12
python 4.py 466ms 1.8ms 9.4MB 453ms 0ms cpython 3.13.5
python 4.py 552ms 2.6ms 83.9MB 513ms 27ms pypy 3.10.16
zig 1.zig 565ms 2.4ms 1.8MB 553ms 0ms zig 0.14.1

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 3686ms 3.1ms 1.4MB 3677ms 0ms zig 0.14.1
python 8.py timeout 0.0ms 14.8MB 40ms 10ms cpython 3.13.5
python 8.py timeout 0.0ms 95.4MB 777ms 80ms pypy 3.10.16
python 8.py timeout 0.0ms 14.2MB 37ms 10ms pyston 3.8.12

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 924ms 1.9ms 1.3MB 917ms 0ms zig 0.14.1
python 8.py timeout 0.0ms 14.5MB 47ms 10ms cpython 3.13.5
python 8.py timeout 0.0ms 95.8MB 1297ms 173ms pypy 3.10.16
python 8.py timeout 0.0ms 13.7MB 60ms 20ms pyston 3.8.12

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 233ms 1.2ms 1.3MB 223ms 0ms zig 0.14.1
python 8-m.py 1962ms 22ms 93.3MB 6350ms 247ms pypy 3.10.16
python 8.py timeout 0.0ms 14.0MB 83ms 20ms cpython 3.13.5
python 8.py timeout 0.0ms 13.1MB 137ms 33ms pyston 3.8.12