The Computer Language
25.02 Benchmarks Game

Python 3 versus Go

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

If the fastest programs are flagged * possible hand-written vector instructions or "unsafe" or naked ffi, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #3 8.36 33.35 3,846 975 5.31
Go #8 46.15 46.26—46.33 3,207 500 5.43
Go 12.27 49.09 4,903 906 5.41
Go #2 12.36 49.40 16,966 903 5.43
Python 3 #6 943.88 942.63 11,874 391 3.58
Python 3 #4 311.18 1,221.85 28,701 960 5.27
Python 3 #8 2,457.09 2,455.59 11,874 414 5.65
n-body      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #3 6.39 6.41 3,191 1207 5.43
Go 7.02 7.09—7.27 3,228 1316 5.36
Go #2 7.04 7.06 3,203 1222 5.35
Go #8 9.60 9.64 3,191 1224 5.47
Python 3 372.41 371.23 12,198 1201 5.23
Python 3 #2 442.06 440.87 12,554 1247 5.24
Python 3 #8 529.38 528.16 12,497 1172 4.94
spectral-norm      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #8 5.34 5.36 3,838 429 5.35
Go 5.34 5.36 4,059 417 5.35
Go #4 1.43 5.69 4,174 555 5.45
Go #2 1.51 5.70 4,317 674 5.56
Python 3 #6 349.68 348.48 13,660 334 5.44
Python 3 #4 90.37 352.91 34,693 415 5.41
Python 3 #8 386.45 385.07 12,833 334 5.08
Python 3 #7 109.91 421.84 34,578 425 5.30
mandelbrot      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #4 3.77 15.02 37,970 912 5.49
Go #3 3.78 15.03 38,101 900 5.82
Go 5.04 20.05 35,787 829 5.40
Go #8 26.70 26.77 3,199 500 5.39
Go #2 6.87 27.32 35,549 843 5.69
Go #6 6.91 27.48 35,119 707 5.69
Python 3 #7 182.94 723.28 62,173 698 5.52
Python 3 #3 879.41 877.96 45,085 319 5.26
Python 3 #2 237.64 937.87 230,973 790 5.42
Python 3 #5 260.63 1,033.16 61,620 463 5.48
Python 3 #8 1,577.29 1,575.80 45,031 379 4.84
fasta      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go 3.74 3.76 3,207 1055 5.36
Go #2 1.27 4.08 12,644 1405 5.51
Go #3 1.52 4.10 5,095 1362 5.29
Go #8 11.22 11.54—11.80 9,052 880 5.55
Python 3 #3 39.03 38.30—47.80 12,218 1007 5.32
Python 3 #2 39.06 38.61—46.82 12,415 1126 5.21
Python 3 #5 27.95 54.20—54.96 1,190,347 1951 5.52
Python 3 57.39 56.94—65.76 12,100 823 5.06
Python 3 #8 153.17 153.78—158.43 11,915 738 5.04
k-nucleotide      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #7 7.58 28.83—29.08 168,186 1613 5.42
Go #3 8.20 29.98—30.69 150,413 1729 5.63
Go #6 8.30 30.22—30.75 150,442 1596 5.79
Go #4 9.27 32.00—35.21 144,650 1552 5.11
Go #8 61.38 62.37—62.83 558,379 752 5.20
Python 3 #3 46.55 182.32—187.37 674,185 1970 5.68
Python 3 #4 76.67 233.00—239.32 523,751 663 4.89
Python 3 #8 234.08 235.36—236.89 642,265 525 5.15
Python 3 234.20 235.10—237.16 515,047 499 5.34
Python 3 #9 66.67 236.43—238.45 392,184 614 4.09
reverse-complement      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #2 2.22 2.34—2.39 822,211 614 4.79
Go #3 2.50 2.62—2.66 821,985 609 4.88
Go #6 1.93 3.46—3.52 1,277,608 1340 4.77
Python 3 #3 4.96 4.95 523,801 803 5.28
Python 3 #5 4.18 7.46—7.50 2,418,156 960 5.36
Python 3 #2 10.09 10.13—10.24 1,837,285 440 5.32
Python 3 10.43 10.43—10.59 2,040,713 484 5.28
Python 3 #6 7.59 11.07—11.11 2,795,930 821 5.37
Python 3 #4 13.47 13.44—13.88 4,109,324 343 5.05
Go #5   Bad Output  
Go   Empty  
binary-trees      [ Contentious. Different approaches. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Go #6 27.93 29.32—29.66 416,195 618 5.43
Go #2 14.21 56.45—56.55 635,613 672 5.41
Go #3 14.90 57.97—58.17 329,499 806 5.29
Go #5 14.68 57.76—58.07 386,056 957 5.41
Go 32.05 59.81—60.00 243,114 488 5.21
Go #7 32.57 61.40—61.53 241,345 531 5.30
Python 3 #2 100.49 100.69—101.09 281,829 344 5.08
Python 3 #4 33.37 121.32—121.68 460,771 481 5.57
Python 3 34.85 123.08—123.98 445,649 597 5.16
Python 3 #5 35.37 125.71—126.12 806,117 669 5.30
Python 3 #3 51.88 148.91—149.87 819,077 1247 5.39
pidigits      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* Go #4 0.82 0.84 6,402 689 8.17
Go 1.15 1.22—1.31 7,533 715 11.71
* Go #3 1.17 1.35—1.49 6,885 610 8.50
* Python 3 #3 1.35 1.28—1.32 20,009 573 5.34
Go #2 1.76 1.90—2.03 7,823 740 7.70
Go #6 2.47 2.48 10,703 727 5.59
Python 3 #4 4.63 4.60 12,718 348 4.88
Go #7 5.00 5.65 10,527 702 6.17
Python 3 #5   Empty  
regex-redux      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* Python 3 #2 1.41 2.65 191,300 1411 5.48
Go #5 3.23 5.40—5.44 297,800 817 8.13
Python 3 8.96 16.47—16.75 459,624 515 5.47
Go #4 14.49 35.20—35.71 349,008 832 8.44
Go #3 25.15 61.72—63.46 336,585 836 5.60
Go 25.79 61.91—62.99 301,662 749 5.85
Python 3

Python 3.13.0

Go

go version go1.23.1 linux/amd64
GOAMD64=v2