The Computer Language
24.11 Benchmarks Game

Python 3 versus Java 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
Java #3 39.96 44,308 1264 40.06
Java 10.85 44,612 1289 42.80
Java #2 45.77 42,552 520 45.83
Java #8 45.90 42,568 517 45.97
Python 3 #6 1,033.31 19,312 391 1,033.27
Python 3 #4 302.37 19,312 960 1,196.45
Python 3 #8 2,259.59 19,312 414 2,259.50
n-body
source secs mem gz cpu secs
Java #4 6.88 42,028 1495 6.91
Java #5 7.30 43,424 1435 7.36
Java #2 7.48 42,260 1430 7.52
Java #3 7.49 42,292 1436 7.52
Java #8 7.59 42,924 1322 7.64
Java 7.84 42,652 1437 7.88
Python 3 355.06 19,312 1201 355.05
Python 3 #2 374.16 19,312 1247 374.14
Python 3 #8 518.11 19,312 1172 518.09
spectral-norm
source secs mem gz cpu secs
Java #8 5.43 43,368 453 5.49
Java #3 1.57 44,160 762 5.93
Java #2 1.61 43,028 956 6.08
Python 3 #6 347.53 19,316 334 347.52
Python 3 #4 90.52 19,308 415 359.95
Python 3 #8 379.97 19,440 334 379.96
Python 3 #7 97.11 19,316 425 380.79
mandelbrot
source secs mem gz cpu secs
Java #2 4.08 82,216 802 16.06
Java #4 4.41 105,000 667 16.14
Java #6 4.19 82,232 808 16.42
Java 24.50 42,272 671 24.57
Java #3 6.96 82,972 910 27.54
Java #8 27.67 45,844 441 27.79
Python 3 #7 172.20 19,312 698 687.68
Python 3 #3 861.76 19,312 319 861.73
Python 3 #2 235.71 95,164 790 926.30
Python 3 #5 257.00 19,312 463 1,026.96
Python 3 #8 1,528.00 19,364 379 1,527.73
fasta
source secs mem gz cpu secs
Java #4 3.28 44,352 1528 3.40
Java #6 1.16 49,848 2549 3.71
Java #5 1.24 49,640 2478 4.13
Java #2 4.45 48,896 1259 4.60
Java #8 15.11 77,032 894 15.49
Python 3 #2 39.00 19,312 1126 39.00
Python 3 #3 39.12 19,312 1007 39.12
Python 3 #5 27.86 827,284 1951 53.94
Python 3 57.21 19,312 823 57.20
Python 3 #8 259.98 19,312 730 259.80
k-nucleotide
source secs mem gz cpu secs
Java 4.92 427,448 1821 15.77
Java #6 7.27 426,032 1614 25.17
Java #3 7.34 426,540 1642 25.47
Java #4 34.33 197,748 1887 34.67
Java #5 22.10 222,396 2225 48.14
Java #8 78.46 2,083,000 786 80.86
Python 3 #3 50.15 262,368 1970 185.77
Python 3 #4 79.01 506,112 663 236.67
Python 3 238.45 499,072 499 237.78
Python 3 #8 238.78 623,448 525 237.93
Python 3 #9 68.33 379,392 614 238.74
reverse-complement
source secs mem gz cpu secs
Java #6 3.15 2,032,996 760 3.79
Java #5 4.72 1,097,732 1115 4.84
Python 3 #3 4.86 507,712 803 4.86
Java #4 5.65 1,891,656 656 5.77
Java #7 23.98 1,037,708 1654 6.26
Python 3 #5 4.09 1,500,716 960 7.41
Python 3 #2 10.08 1,788,136 440 10.08
Python 3 10.29 1,986,440 484 10.29
Python 3 #6 7.38 2,484,372 821 10.89
Python 3 #4 13.41 4,002,688 343 13.41
Java #3   Bad Output  
binary-trees
source secs mem gz cpu secs
Java #4 4.41 1,821,244 846 5.14
Java #6 4.87 1,782,568 535 5.63
Java #3 4.85 1,769,500 546 5.65
Java #2 5.09 1,820,068 558 5.83
Java #8 6.57 1,767,108 596 7.29
Java #7 2.62 1,803,192 841 8.14
Python 3 #2 100.90 271,872 344 100.89
Python 3 #4 33.61 276,992 481 121.96
Python 3 #5 35.49 274,816 669 126.17
Python 3 36.12 276,992 597 127.68
Python 3 #3 52.28 671,872 1247 149.07
Python 3 #8 558.92 798,336 535 558.85
pidigits
source secs mem gz cpu secs
* Java #3 0.80 41,900 770 0.83
* Python 3 #3 1.26 19,312 573 1.26
* Java #2 1.29 45,768 944 1.37
Python 3 #4 4.54 19,312 348 4.54
Java 7.68 482,056 807 8.75
Python 3 #5   Failed  
regex-redux
source secs mem gz cpu secs
* Python 3 #2 1.35 168,236 1411 2.64
Java #2 1.55 372,764 2201 3.16
Python 3 8.91 432,220 515 16.44
Java 8.47 575,552 875 16.69
Java #6 5.60 1,237,440 746 17.12
Java #3 5.25 611,476 935 17.25
Python 3

Python 3.13.0

Java

java 23 2024-09-17
Java HotSpot(TM) 64-Bit Server VM
(build 23+37-2369,
mixed mode, sharing)