The Computer Language
Benchmarks Game

C++ g++ versus Python 3 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.

mandelbrot
source secs mem gz busy cpu load
C++ g++ 0.84 34,604 3542 3.28 98% 99% 98% 95%
Python 3 172.58 12,216 688 689.62 100% 100% 100% 100%
spectral-norm
source secs mem gz busy cpu load
C++ g++ 0.72 1,216 1044 2.86 100% 100% 99% 100%
Python 3 118.40 22,912 407 470.86 99% 99% 99% 100%
n-body
source secs mem gz busy cpu load
C++ g++ 4.09 1,800 1808 4.13 100% 0% 0% 0%
Python 3 586.17 8,012 1196 589.84 0% 0% 0% 100%
fannkuch-redux
source secs mem gz busy cpu load
C++ g++ 4.91 1,912 1482 19.45 100% 99% 97% 100%
Python 3 367.49 12,288 950 1,454.68 100% 98% 99% 98%
fasta
source secs mem gz busy cpu load
C++ g++ 0.78 2,468 2751 1.62 8% 99% 99% 3%
Python 3 39.10 846,628 1947 70.52 43% 8% 61% 69%
binary-trees
source secs mem gz busy cpu load
C++ g++ 1.04 154,824 1122 3.74 88% 100% 88% 86%
Python 3 49.35 278,628 589 174.26 95% 86% 86% 86%
k-nucleotide
source secs mem gz busy cpu load
C++ g++ 1.95 156,372 1631 5.95 73% 70% 92% 70%
Python 3 46.37 239,472 1967 176.69 94% 95% 98% 94%
reverse-complement
source secs mem gz busy cpu load
C++ g++ 0.63 499,704 2093 0.64 0% 100% 2% 0%
Python 3 7.16 1,005,968 814 10.65 20% 53% 47% 29%
pidigits
source secs mem gz busy cpu load
C++ g++ 0.60 4,944 986 2.38 100% 100% 98% 100%
Python 3 1.28 12,336 567 1.30 1% 0% 1% 100%
regex-redux
source secs mem gz busy cpu load
C++ g++ 1.08 203,816 1315 3.38 78% 99% 65% 73%
Python 3 1.36 112,052 1403 2.64 40% 88% 32% 33%
C++ g++

g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0

Python 3

Python 3.9.0