The Computer Language
Benchmarks Game

Python 3 programs versus C++ g++

by benchmark task performance

pidigits
source secs mem gz cpu cpu load
Python 3 3.41 9,992 382 3.40 1% 2% 100% 1%
C++ g++ 1.89 3,740 508 1.89 2% 99% 0% 2%
regex-redux
source secs mem gz cpu cpu load
Python 3 14.87 433,868 486 28.02 32% 45% 84% 29%
C++ g++ 6.75 183,256 700 9.80 100% 39% 8% 0%
reverse-complement
source secs mem gz cpu cpu load
Python 3 2.93 265,636 800 4.28 80% 46% 21% 2%
C++ g++ 0.59 217,564 2275 0.84 26% 78% 12% 34%
k-nucleotide
source secs mem gz cpu cpu load
Python 3 72.35 229,040 1937 268.72 98% 94% 91% 94%
C++ g++ 7.15 164,080 1252 24.21 82% 83% 80% 96%
binary-trees
source secs mem gz cpu cpu load
Python 3 126.07 831,740 596 474.55 93% 93% 93% 99%
C++ g++ 3.36 158,320 846 10.59 81% 82% 78% 75%
mandelbrot
source secs mem gz cpu cpu load
Python 3 250.62 52,752 686 1,000.26 100% 100% 100% 100%
C++ g++ 5.82 33,952 726 22.40 96% 95% 95% 100%
fannkuch-redux
source secs mem gz cpu cpu load
Python 3 501.72 54,708 944 1,967.92 98% 97% 100% 99%
C++ g++ 10.58 2,520 950 41.88 100% 100% 99% 98%
fasta
source secs mem gz cpu cpu load
Python 3 113.03 7,860 977 112.99 1% 100% 0% 1%
C++ g++ 1.47 9,484 2291 5.13 88% 88% 87% 88%
spectral-norm
source secs mem gz cpu cpu load
Python 3 180.01 55,892 437 714.86 99% 100% 99% 100%
C++ g++ 2.01 1,792 1044 8.00 100% 100% 100% 100%
n-body
source secs mem gz cpu cpu load
Python 3 836.27 7,756 1181 836.06 0% 1% 1% 100%
C++ g++ 9.30 1,712 1763 9.29 100% 1% 1% 0%
Python 3

Python 3.6.0 (default, Feb 5 2017, 10:29:14) [GCC 5.4.0 20160609] on linux
--enable-optimizations
make profile-opt

C++ g++

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609