The Computer Language
24.06 Benchmarks Game

Python 3 versus Go fastest performance

How the programs are written matters! Always look at the source code.

If the fastest programs are hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux
source secs mem gz cpu secs
Go #3 8.36 19,656 975 33.34
Go 11.77 19,656 906 46.92
Go #2 11.83 19,656 903 47.16
Python 3 #6 895.57 19,652 391 895.53
Python 3 #4 291.14 19,652 960 1,150.83
n-body
source secs mem gz cpu secs
Go #3 6.38 19,688 1207 6.39
Go 7.00 19,688 1316 7.02
Go #2 7.03 19,688 1222 7.04
Python 3 354.45 19,652 1201 354.43
Python 3 #2 360.53 19,652 1247 360.52
spectral-norm
source secs mem gz cpu secs
Go 5.33 20,116 417 5.34
Go #4 1.43 20,340 555 5.68
Go #2 1.50 20,148 674 5.69
Python 3 #7 85.35 19,660 425 338.99
Python 3 #6 343.12 19,660 334 343.11
Python 3 #8 89.19 19,660 415 354.24
mandelbrot
source secs mem gz cpu secs
Go #3 3.77 35,328 900 14.99
Go #4 3.77 35,328 912 15.00
Go 5.01 33,024 829 19.93
Go #2 6.86 33,152 843 27.28
Go #6 6.91 32,896 707 27.48
Python 3 #7 158.82 19,652 698 634.14
Python 3 #3 813.16 19,652 319 813.13
Python 3 #2 212.22 102,584 790 846.26
Python 3 #5 247.80 19,652 463 989.79
pidigits
source secs mem gz cpu secs
Go #4 0.96 19,700 689 0.98
Python 3 #3 1.33 19,652 573 1.33
Go 1.34 19,700 715 1.36
Go #3 1.65 19,700 610 1.69
Go #2 2.18 19,700 740 2.23
Go #8 2.51 19,700 727 2.51
Python 3 #4 4.61 19,652 348 4.61
Go #7 5.19 19,700 702 5.98
Python 3 #5   Failed  
regex-redux
source secs mem gz cpu secs
Python 3 #2 1.35 168,036 1411 2.63
Go #5 3.22 320,724 817 5.39
Python 3 8.84 432,748 515 16.23
Go #4 14.78 397,240 832 36.01
Go #3 25.54 370,524 836 61.42
Go 25.87 311,444 749 64.23
fasta
source secs mem gz cpu secs
Go 3.74 19,664 1055 3.74
Go #2 1.27 19,664 1405 4.07
Go #3 1.50 19,664 1362 4.08
Python 3 #2 37.94 19,652 1126 37.94
Python 3 #3 38.31 19,652 1007 38.30
Python 3 #5 28.13 827,220 1951 55.72
Python 3 57.01 19,652 823 57.01
k-nucleotide
source secs mem gz cpu secs
Go #7 7.53 162,816 1613 28.78
Go #6 8.26 145,152 1596 30.01
Go #3 8.29 145,152 1729 30.02
Go #4 9.22 139,776 1552 30.55
Python 3 #3 50.62 262,400 1970 193.35
Python 3 #8 73.69 506,368 663 226.37
Python 3 #9 63.78 379,776 614 228.11
Python 3 232.37 499,456 499 231.68
reverse-complement
source secs mem gz cpu secs
Go #2 2.24 800,512 614 2.34
Go #3 2.50 800,128 609 2.60
Go #6 1.93 1,246,404 1340 3.43
Python 3 #3 4.82 508,760 803 4.82
Python 3 #5 4.03 1,500,508 960 7.30
Python 3 #2 10.13 1,788,624 440 10.12
Python 3 10.36 1,986,924 484 10.36
Python 3 #6 7.71 2,484,208 821 11.18
Python 3 #4 13.85 4,003,072 343 13.85
Go #5   Bad Output  
Go   Failed  
binary-trees
source secs mem gz cpu secs
Go #6 27.68 404,224 618 29.07
Go #2 13.86 594,740 672 55.04
Go #5 14.29 317,028 957 56.60
Go #3 14.72 343,248 806 57.03
Go 31.84 237,200 488 59.20
Go #7 31.79 250,476 531 59.90
Python 3 #2 105.82 272,384 344 105.81
Python 3 #5 34.55 274,944 669 123.08
Python 3 35.50 277,632 597 126.38
Python 3 #4 34.68 277,504 481 127.31
Python 3 #3 49.75 672,384 1247 143.18
Python 3

Python 3.12.3

Go

go version go1.22.3 linux/amd64
GOAMD64=v2