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

1

6

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

Rovner answered 15/4, 2010 at 8:49 Comment(0)
M
10

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.

Midmost answered 15/4, 2010 at 9:3 Comment(1)
Thanks for your input. I will probably go with this approach. Boost.Python is really nice.Rovner

© 2022 - 2024 — McMap. All rights reserved.