The Computer Language
24.04 Benchmarks Game

Python 3 versus Ruby fastest performance

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
Ruby #2 139.77 21,120 1462 536.11
Python 3 #6 1,031.38 19,652 391 1,031.34
Python 3 #4 300.68 19,652 960 1,189.39
Ruby 1,380.34 20,992 391 1,380.29
n-body
source secs mem gz cpu secs
Ruby #3 188.71 21,248 1169 188.71
Ruby #2 215.31 21,248 1143 215.31
Python 3 #2 362.72 19,656 1247 362.70
Python 3 368.32 19,656 1201 368.30
spectral-norm
source secs mem gz cpu secs
Ruby 126.55 22,144 299 126.54
Ruby #4 129.16 22,912 333 129.16
Ruby #5 64.82 27,520 764 236.48
Python 3 #7 90.77 19,656 425 359.32
Python 3 #6 359.89 19,656 334 359.83
Python 3 #8 98.97 19,656 415 386.79
mandelbrot
source secs mem gz cpu secs
Ruby #5 151.07 86,272 978 603.13
Python 3 #7 159.49 19,656 698 634.00
Ruby #4 661.22 136,132 862 661.94
Python 3 #3 820.95 19,624 319 820.91
Python 3 #2 232.82 156,340 790 880.90
Ruby #2 259.17 94,336 887 1,034.44
Python 3 #5 274.66 19,628 463 1,094.30
Ruby #3 1,538.89 21,120 313 1,538.80
Ruby #6   Failed  
Ruby #7   Failed  
pidigits
source secs mem gz cpu secs
Python 3 #3 1.31 19,784 573 1.31
Ruby #5 1.56 850,304 494 1.55
Ruby #2 3.22 2,271,624 666 3.22
Python 3 #4 4.73 19,656 348 4.73
Ruby 16.56 104,192 524 16.55
Python 3 #5   Failed  
regex-redux
source secs mem gz cpu secs
Python 3 #2 1.35 168,092 1411 2.62
Python 3 8.83 432,724 515 16.44
Ruby #2 23.19 216,576 444 23.19
Ruby #3 11.84 216,576 730 24.21
Ruby #9 30.10 216,576 327 30.09
fasta
source secs mem gz cpu secs
Ruby #6 23.07 120,064 1070 23.07
Ruby #3 35.52 120,064 1004 35.52
Python 3 #2 38.53 19,652 1126 38.53
Python 3 #3 38.86 19,780 1007 38.86
Python 3 #5 26.54 827,148 1951 53.26
Python 3 60.37 19,652 823 60.37
Ruby #5 91.70 22,784 1000 91.69
Ruby #2 93.97 147,548 747 93.97
Ruby #4 95.74 266,496 864 95.73
k-nucleotide
source secs mem gz cpu secs
Python 3 #3 48.64 262,016 1970 184.81
Ruby #7 256.92 393,216 792 255.31
Ruby #2 255.78 181,700 426 255.60
Python 3 #8 87.79 506,880 663 262.44
Python 3 #9 77.06 380,416 614 263.65
Ruby #3 272.84 203,672 546 273.06
Python 3 275.64 500,224 499 274.74
Ruby 84.88 172,436 583 300.65
reverse-complement
source secs mem gz cpu secs
Python 3 #3 5.18 509,108 803 5.18
Python 3 #5 4.07 1,500,240 960 7.41
Python 3 #2 10.46 1,788,876 440 10.46
Python 3 10.69 1,987,304 484 10.69
Ruby #5 10.77 1,624,300 301 10.76
Python 3 #6 7.86 2,484,084 821 11.49
Ruby #4 6.88 2,510,956 608 12.51
Python 3 #4 13.91 4,003,712 343 13.91
Ruby #3 9.57 4,232,604 490 17.72
Ruby #2 24.46 1,001,852 272 24.46
Ruby 18.75 5,147,124 521 36.24
binary-trees
source secs mem gz cpu secs
Ruby #4 46.87 478,848 371 46.86
Ruby 48.73 478,976 383 48.72
Ruby #2 48.78 478,976 385 48.76
Ruby #3 50.16 515,924 407 50.14
Ruby #5 18.96 521,984 1016 53.93
Python 3 #2 110.47 273,024 344 110.46
Python 3 #4 34.53 277,632 481 126.59
Python 3 #5 35.74 275,456 669 127.53
Python 3 36.16 277,760 597 128.12
Python 3 #3 55.05 672,384 1247 158.56
Python 3

Python 3.12.2

Ruby

ruby 3.3.0
(2023-12-25
revision 5124f9ac75)
+YJIT [x86_64-linux]