0

I am working on an application that uses C++ code and python code.
Data is shared between the two scripts, C++ <---> python. Right now, I achieve this via SQLite, which very roughly takes care of concurrency , and it works correctly. The problem is that it's very slow for my purpose.
My question is: how can I share data among python and C++ in a fast way?
I read that Boost can be used to implement python code in C++, but since in my python code I work with keras/tensorflow, I don't think that solution works for me.
I read that sockets are supposed to be slower than a local database, but I haven't tested this yet. Thanks!

maurock
  • 527
  • 1
  • 7
  • 22
  • 1
    If you want the same code in one application (share using memory) Cython is best. If not, use an API or shared database. – Neil Jul 12 '19 at 15:15
  • I cannot have the whole code in one application. The shared database is my current solution, but it's too slow. For the API you mean a connection with sockets? – maurock Jul 12 '19 at 15:51
  • One solution would be to create Python function wrappers for your C++ functions and then bind them together. [Here's a tutorial on Python C++ binding](https://www.hardikp.com/2017/12/30/python-cpp/). – zmike Jul 12 '19 at 18:30
  • @zmike do you know if it's possible to create such python wrappers for neural networks? – maurock Jul 13 '19 at 10:29
  • @maurocomi While I don't have experience with neural networks, I'm inclined to say yes. The function prototype may be declared in python but the actual implementation is in C++. Your python program would be calling the C++ functions as if they were Python functions. – zmike Jul 13 '19 at 13:40

0 Answers0