[Python] How to expose a Python package to C# using python .Net vs ZeroMQ or other

Discussão em 'Python' iniciado por Stack, Agosto 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am developing an application which is written in Python3 and is composed of a Python library/package (which contains the core functionality) and a Python application which will provide a cli shell and handles user commands.

    In addition the functionality contained within the Python package must be exposed to existing gui applications written in C# (using the Microsoft .Net framework).

    I've done a fair bit of research into how this might be done and have come up with a few potential solutions.

    1. Use Python.Net to implement a Python script within a C# application that imports my python package and calls the desired methods/attributes. I haven't been able to get this to work on monodevelop myself yet but this seems to be a popular option despite there not being much documentation in regards to my use case.
    2. Embed my Python library as a DLL using CFFI. This option seems like it would not take a lot of work but it's hard to see how I would maintain my interfaces/what I am exposing to someone using the DLL in C#. This option also doesn't seem to be support by a lot of documentation pertaining to my use case.
    3. Create a small Python application which imports my python package and exposes its functionality via ZeroMQ or gRPC. This seems to be the most flexible option with ample documentation however I am concerned about latency as ultimately this tool is used for hardware control.

    Note I am not well versed in C# and will be doing the majority of the development in linux.

    I'm really looking to get feedback on which option will provide the best balance between a clean interface to my library and low latency/good performance (emphasis on the later).

    Continue reading...

Compartilhe esta Página