Calling Python from C# - please help

Samuele Pedroni pedronis at
Tue Sep 17 15:02:51 EDT 2002

Mark Hammond <mhammond at> wrote in message
3%Dh9.15217$Ee4.45118 at
> Syver Enstad wrote:
> >
> > Now that J# (Java .NET) has been released, I was wondering about the
> > possibility of compiling Jython with the MS J# compiler to create a
> > Jython .NET. Has anyone considered the possibility?
> I'd love to see some Jython technology used for .NET.  At the time
> Python.NET started, there was very strict NDA, so discussing the project
> with jython-dev, or even python-dev, was taboo.  Greg Stein and I made a
> pragmatic decision to go with the p2c tool as a framework over jython as
> we alrady had experience with p2c and didnt have the time-lines to
> understand jython before embarking on our pilot code.

How were you going to support eval and exec?

For the moment the unload granularity of .NET is AppDomains only and only
upon explicit request, and types/modules/assemblies are not garbage
collected but simply live as much as the AppDomain,

that's OK for static languages, or environments with a clear run/design time
distinction (one can setup an AppDomain and tear it down for each
run-cycle), or for running scripts in isolation but not if one wants IL/JIT
speed for a enviroment that allows for redefinitions and eval, ...

In Jython we create Java bytecode and dynamically load classes for all the
code, also eval code because in Java classes are elegible for garbage

In .NET it seems one needs a pure interpreter that does not compile to IL
for exec and eval support, and that seems what JScript does for jsc compiled
code containing eval, that means the script is compiled but the evaluated
code is only interpreted,

otherwise a long running process using eval could go out of memory.

That's something people wanting to write a feature complete impl of Pyhton
for .NET should consider or wait MS to implement a more
dynamic-environment-friendly unload policy.

This is also an issue versus runtime subclassing of framework classes,
Jython creates distinct concrete Java subclasses each time a Java class is
subclassed, under .NET one should probably limits this  ...


More information about the Python-list mailing list