C++ vs Python, the cost of the abstraction

asked 2015-11-09 05:15:15 -0600

chr0x gravatar image

Hello guys.

I'm working in a computer vision software for a while, and I always used C++ to code the system. The C++ was chosen because of performance. The software works with video input and have to normalize various aspects of a frame in each second and realize a classification for each frame (~ 30 classifications per second).

I was using Random Forests to classify these frames but now I'm migrating to Convolutional Neural Networks.

I always loved Python, and whenever I have to develop a external/personal project using opencv + machine learning I use Python, not C++. So I was thinking in begin this module (the CNN module) in Python instead of C++ (the rest of the system will still being written in C++).

My question is... A time ago I read that Python abstraction costs are much bigger that C++ abstraction's costs... How much? If I write a CNN that have to make at least 30 classifications per second, in python, it will be work? it will be slow? There's any text that lists the performance differences in a good quantitative way?

Thanks.

edit retag flag offensive close merge delete

Comments

The files should be the same, so you can use Python for training and use the classifiers in the C++ project. Personally I have not tested in comparison the Python + OpenCV and C++ + OpenCV, but I am sure the first one is slower... You know, maybe for a detection of an object in a photo, it may be 5-10 ms slower (the numbers are not real!!), but in a huge training application, this may lead even to 1 day more... So I would suggest the C++. You can code it in C++ and at home do it in Python (in parallel), to see the differences ;)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-09 06:45:31 -0600 )edit
1

The Computer Language Benchmarks Game shows that C++ is much faster than python. Looking at spectral-norm test C++ is 125x faster than Python using 1/33 memory

C++:  2.01secs with 1772KB
Python: 250secs with 58892KB
pklab gravatar imagepklab ( 2015-11-09 11:03:17 -0600 )edit