Lua VS Python benchmarks

Current benchmark data was generated on Tue Jul 01 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 1158ms 1.0ms 96.1MB 1093ms 53ms pypy 3.10.16
lua 1.lua 3562ms 89ms 173.0MB 3437ms 113ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 105.0MB 4953ms 37ms lua 5.4.7
python 1.py timeout 0.0ms 41.0MB 4963ms 17ms cpython 3.13.5
python 1.py timeout 0.0ms 40.5MB 4753ms 233ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 93ms 0.2ms 68.8MB 67ms 17ms pypy 3.10.16
lua 1.lua 289ms 0.8ms 15.8MB 260ms 10ms luajit 2.1.0-beta3
python 1.py 477ms 1.2ms 11.9MB 453ms 13ms pyston 3.8.12
python 1.py 718ms 3.5ms 13.0MB 707ms 0ms cpython 3.13.5
lua 1.lua 828ms 3.7ms 16.9MB 810ms 0ms lua 5.4.7

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1.4ms 0.1ms 2.0MB 0ms 0ms lua 5.4.7
lua 1.lua 1.4ms 0.2ms 2.4MB 0ms 0ms luajit 2.1.0-beta3
python 1.py 12ms 0.7ms 7.6MB 10ms 0ms pyston 3.8.12
python 1.py 15ms 1.2ms 8.8MB 10ms 0ms cpython 3.13.5
python 1.py 30ms 0.9ms 51.7MB 6ms 12ms pypy 3.10.16

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 2196ms 9.7ms 202.5MB 2077ms 100ms pypy 3.10.16
lua 1.lua timeout 0.0ms 107.4MB 4950ms 40ms lua 5.4.7
lua 1.lua timeout 0.0ms 149.3MB 4923ms 60ms luajit 2.1.0-beta3
python 1.py timeout 0.0ms 94.1MB 4960ms 27ms cpython 3.13.5
python 1.py timeout 0.0ms 130.3MB 4930ms 57ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 385ms 4.5ms 104.7MB 323ms 50ms pypy 3.10.16
lua 1.lua 1431ms 31ms 31.3MB 1400ms 17ms luajit 2.1.0-beta3
lua 1.lua 2403ms 38ms 28.8MB 2383ms 3ms lua 5.4.7
python 1.py 3347ms 32ms 37.4MB 3317ms 13ms cpython 3.13.5
python 1.py timeout 0.0ms 48.9MB 4953ms 37ms pyston 3.8.12

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 4.lua 715ms 1.4ms 2.4MB 710ms 0ms luajit 2.1.0-beta3
python 2.py 1358ms 8.1ms 58.1MB 1333ms 10ms pypy 3.10.16
python 1.py 2644ms 7.4ms 57.0MB 2620ms 10ms pypy 3.10.16
lua 4.lua timeout 0.0ms 2.3MB 4990ms 0ms lua 5.4.7
python 1.py timeout 0.0ms 8.9MB 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
lua 4.lua 81ms 9.6ms 2.3MB 73ms 0ms luajit 2.1.0-beta3
python 2.py 182ms 1.2ms 57.9MB 160ms 10ms pypy 3.10.16
python 1.py 304ms 1.2ms 57.1MB 280ms 10ms pypy 3.10.16
python 1.py 921ms 6.9ms 8.4MB 910ms 0ms pyston 3.8.12
lua 4.lua 1148ms 64ms 2.3MB 1137ms 0ms lua 5.4.7
python 2.py 1314ms 5.3ms 8.3MB 1300ms 0ms pyston 3.8.12
python 2.py 2943ms 21ms 9.0MB 2930ms 0ms cpython 3.13.5
python 1.py 3003ms 91ms 9.0MB 2990ms 0ms cpython 3.13.5

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 4063ms 3.7ms 2.5MB 4053ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.4MB 4990ms 0ms lua 5.4.7
python 8.py timeout 0.0ms 14.8MB 33ms 10ms cpython 3.13.5
python 8.py timeout 0.0ms 95.9MB 787ms 80ms pypy 3.10.16
python 8.py timeout 0.0ms 14.4MB 33ms 10ms pyston 3.8.12

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1020ms 2.2ms 2.4MB 1010ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.1MB 4990ms 0ms lua 5.4.7
python 8.py timeout 0.0ms 14.5MB 47ms 13ms cpython 3.13.5
python 8.py timeout 0.0ms 95.6MB 1280ms 180ms pypy 3.10.16
python 8.py timeout 0.0ms 13.6MB 60ms 13ms pyston 3.8.12

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 258ms 0.3ms 2.3MB 250ms 0ms luajit 2.1.0-beta3
python 8-m.py 1948ms 18ms 92.9MB 6303ms 253ms pypy 3.10.16
lua 1.lua timeout 0.0ms 2.0MB 4990ms 0ms lua 5.4.7
python 8.py timeout 0.0ms 14.3MB 80ms 20ms cpython 3.13.5
python 8.py timeout 0.0ms 13.1MB 150ms 30ms pyston 3.8.12