简体   繁体   中英

Alternatives for interaction between C# and Python application -- Pythonnet vs DLL vs shared memory vs messaging

We have a big C# application, would like to include an application written in python and cython inside the C#

Operating system: Win 10 Python: 2.7 .NET: 4.5+

I am looking at various options for implementation here. (1) pytho.net - embed the python inside the C# application, if I have abc.py and inside the C#, while the abc.py has a line of "import numpy", does it know how to include all python's dependencies inside C#?

(2) Convert the python into.dll - Correct me if i am wrong, this seems to be an headache to include all python files and libraries inside clr.CompileModules. Is there any automatically solution? (and clr seems to be the only solution i have found so far for building dll from python.

(3) Convert.exe to.dll for C# - I do not know if i can do that, all i have is the abc.exe constructed by pyinstaller

(4) shared memory seems to be another option, but the setup will be more complicated and more unstable? (because one more component needs to be taken care of?)

(5) Messaging - zeromq may be a candidate for that.

Requirements: Both C# and python have a lot of classes and objects and they need to be persistent C# application need to interact with Python Application They run in real-time, so performance for communication does matter, in milliseconds space.

I believe someone should have been through a similar situation and I am looking for advice to find the best suitable solution, as well as pros and cons for above solution. Stability comes first, then the less complex solution the better it is.

For variant 1: in my TensorFlow binding I simply add the content of a conda environment to a NuGet package. Then you just have to point Python.NET to use that environment instead of the system Python installation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM