Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ or Python for an Extensive Math Program?

Tags:

c++

python

math

I'm debating whether to use C++ or Python for a largely math-based program.

Both have great math libraries, but which language is generally faster for complex math?


1 Answers

You could also consider a hybrid approach. Python is generally easier and faster to develop in, specially for things like user interface, input/output etc.

C++ should certainly be faster for some math operations (although if your problem can be formulated in terms of vector operations or linear algebra than numpy provides a python interface to very efficient vector manipulations).

Python is easy to extend with Cython, Swig, Boost Python etc. so one strategy is write all the bookkeeping type parts of the program in Python and just do the computational code in C++.

like image 173
robince Avatar answered May 30 '26 14:05

robince



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!