python.netpypypython-embeddingpython-stackless

Is it possible to embed PyPy into a .NET application?


I would like to embed a Python interpreter into my .NET application. I'm aware of IronPython, of course, but I'm specifically interested in PyPy, because of its stackless support and microthreads.

However, while PyPy can be built against the CLI, it looks like that just gives you a standalone Python interpreter a la python.exe. I haven't been able to find any documentation for building something that can actually be embedded inside a .NET host application.

Is there a way to use (stackless) PyPy to run Python scripts from a .NET app, and allow those scripts to interact with CLR objects provided by the host application?


Solution

  • PyPy's CLI backend is not as mature as C backend and also does not integrate as well with .NET libraries. While normal PyPy compiled to C is production ready, I wouldn't call the .NET version production ready. It's also missing the JIT (although some work has been done in this area) and microthreads. Unless someone steps in, IronPython seems to be the only viable option as of now.