Reputation: 59
I'm writing a DLL (Windows, MS VS 17) in C++ which requires to call a Python script at some point - it should read a json-encoded string, process it and give back the json-encoded result. There is no need for asynchronous mode or "speed of light", but I need more or less fast response - i. e. within 1-5 seconds max. Here are the approaches I considered and the comments:
localhost
) / pipe. Both seem to be an overkill for such a task - I do not have a continuous flow of data which changes constantly. Besides, in Windows it might be a pain.import
, which imports a package, installed from pip and, unfortunately, I cannot avoid it. Is there a proper way to work with imports when embedding?Is there a simple way to interoperate between C++ and Python in my case?
Upvotes: 0
Views: 201
Reputation: 179907
Since you're targeting Windows, option (2) is the best, but use a temporary file CreateFile(...FILE_ATTRIBUTE_TEMPORARY)
. That's effectively shared memory (at the OS level, both are managed by the Virtual Memory Manager) but you get file semantics.
Upvotes: 2