First of all, this question is very opinion based!
The cleanest way is to use them in one process and directly contact them. The only difficulty is implementing the correct APIs and C ++ -> Python calls. The disadvantages are the ease of maintenance, as you noted, and the potentially lower reliability (both in the event of a failure, and in most cases a problem) and lower flexibility (are you sure that you will not need to run them on different machines?). Extensibility is best because it is very easy to add more communication or modify existing ones. You can review the service point. Can you use a python application without mapping to C ++? If not for me, I would not have to worry about maintainability.
Then shared memory is the next choice with better maintainability, but with the same other drawbacks. Extensibility is a little worse, but still not so bad. It can be complicated, I donβt know Python support for working with shared memory, for C ++ you can take a look at Boost.Interprocess. The main question I need to check is the synchronization between processes.
Then, network communication. There are many options: from the simplest binary protocol implemented at the socket level to the higher levels mentioned in the comments. It depends on how complex your C ++ β Python connection is and may be in the future. This approach may be more difficult to implement, third-party libraries may be required, but after that it will become extensible and flexible. Usually third-party libraries are based on code generation (Thrift, Protobuf), which does not simplify the build process.
I would not seriously consider the file system or database for this case.
source share