The Computer Language
Benchmarks Game

Python 3 versus Java fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? Look at the other programs. They may seem more-like a fair comparison to you.

regex-redux
source secs mem gz busy cpu load
Python 3 1.36 111,852 1403 2.64 32% 40% 33% 88%
Java 5.58 985,696 929 18.26 81% 77% 84% 85%
pidigits
source secs mem gz busy cpu load
Python 3 1.28 12,024 567 1.29 0% 1% 100% 0%
Java 0.93 36,552 764 0.98 2% 3% 1% 99%
reverse-complement
source secs mem gz busy cpu load
Python 3 7.20 1,005,184 814 10.75 20% 53% 48% 29%
Java 1.54 670,924 2183 3.51 46% 56% 48% 79%
k-nucleotide
source secs mem gz busy cpu load
Python 3 46.28 241,108 1967 176.42 94% 97% 95% 96%
Java 4.98 356,904 1812 16.25 78% 76% 96% 76%
binary-trees
source secs mem gz busy cpu load
Python 3 51.07 278,324 589 178.28 85% 86% 93% 85%
Java 2.48 1,722,848 835 7.88 98% 75% 71% 74%
fasta
source secs mem gz busy cpu load
Python 3 37.32 846,264 1947 71.03 10% 67% 83% 30%
Java 1.21 44,620 2543 3.58 89% 75% 65% 68%
fannkuch-redux
source secs mem gz busy cpu load
Python 3 352.29 12,232 950 1,392.10 97% 99% 100% 99%
Java 10.64 35,192 1282 41.91 99% 98% 99% 97%
mandelbrot
source secs mem gz busy cpu load
Python 3 163.32 12,080 688 642.00 98% 98% 98% 98%
Java 4.15 69,136 796 16.29 98% 99% 98% 99%
spectral-norm
source secs mem gz busy cpu load
Python 3 120.99 13,424 407 479.86 99% 99% 99% 99%
Java 1.63 39,304 756 6.22 95% 97% 95% 95%
n-body
source secs mem gz busy cpu load
Python 3 567.56 8,076 1196 570.95 0% 0% 0% 100%
Java 6.74 35,844 1489 6.82 1% 100% 1% 0%
Python 3

Python 3.9.2

Java

openjdk 16 2021-03-16
OpenJDK Runtime Environment (build 16+36-2231)
OpenJDK 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)