Question

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?

Was it helpful?

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.

OTHER TIPS

No, there's not. CPython had the ability to access .NET libraries using the Python for .NET (see http://pythonnet.github.io/) maintained at github, but aside from IronPython there's never been a way to actually embed a Python interpreter into a .NET application. This was one of its main selling points.

On a related note, IronPython (by default) has a smaller stack size than CPython when it comes to recursion. That is, you must pass a "-X:FullFrames" command-line option to ipy.exe to enable CPython-esque stack frames. Know this isn't as good as PyPy...but it might help:)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top