Python has a rich ecosystem of high-quality packages and libraries. There are several mechanisms for using these libraries from C#/.Net programs, here we look at the highest integration approach where the Python interpreter shares the same process as the .Net program. This is achieved using a bridging library.

Potential application areas

Potential applications:

  1. Rendering of sophisticated plots/graphs using Python's matplotlib
  2. Machine learning classification/prediction using scikitlearn/TensorFlow/PyTorch
  3. Numerical algorithms using Numpy/Scipy

Advantages/Disadvantages

Advantages:

  1. Simple execution model: only a single process needs to be started
  2. Maximum efficiency in data sharing: where "unboxed" values are passed between CLR/Python maximum efficiency is possible as no transfer of data is needed
  3. Fine grained control of threading, execution environment etc.

Disadvantages:

  1. Little isolation: Python and C# parts are not isolated through O/S mechanisms and furthermore the Python part has, in general, the same O/S access rights to the filesystem, network, etc as the C# part
  2. Deployment could be complex as the Python elements need to shipped together with the C# front end (but: it is possible to package a whole Python environment in a single file)

For more information see our dedicated pages at www.quantfns.com/pyinnet/.

QuantFns