It is an often reiterated statement that
Interpreted code is always slower then compiled code. We need speed! That's why we're using C/C++ in our project.
This assumption is based on the correct observation that large loops like for a dot
product of two vectors u
, v
, are faster in C,
double out = 0.0
for (int k=0; k < n; k++) {
out += u[k] * v[k];
}
than in Python:
out = 0.0
for k in range(n):
out[k] += u[k] * v[k]
If you care about speed, you wouldn't do either of the above loops, though. In Python, most everyone does
import numpy
out = numpy.dot(u, v)
anyway. For C/C++, Eigen, CBLAS, and Boost come to mind.
This repository contains a comparison of some common costly numerical operations between C++ and Python.
As always, comments and suggestions are welcome!
The code in this respository is published under the MIT license.