Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed a Python persistance layer into a C++ application - good idea?

say I'm about to write an application with a thin GUI layer, a really fat calculation layer (doing computationally heavy calibrations and other long-running stuff) and fairly simple persistance layer. I'm looking at building the GUI + calculation layer in C++ (using Qt for the gui parts).

Now - would it be a crazy idea to build the persistance layer in Python, using sqlalchemy, and embed it into the C++ application, letting the layers interface with eachother through lightweigth data transfer objects (written in C++ but accessible from python)?

(the other alternative I'm leaning towards would probably be to write the app in Python from the start, using the PyQt wrapper, and then calling into C++ for the computational tasks)

Thanks, Rickard

like image 471
Rickard Avatar asked Apr 15 '10 08:04

Rickard


1 Answers

I would go with the 'alternative' approach:

Write as much as possible in Python (you can use the GUI bindings PyQt or PySide) and then only write the computationally intensive parts (when proven critical for performance) in C++ (have a look at Boost.Python).

Developing in Python should be faster, easier and less error-prone then in C++ (unless you're a very experienced C++ developer; and then still). Exposing C++ via Boost.Python should be easier then the other way around.

like image 195
ChristopheD Avatar answered Nov 18 '22 14:11

ChristopheD