[IronPython] Exporting Python code as an assembly

Michael Foord fuzzyman at voidspace.org.uk
Mon Feb 4 19:55:32 CET 2008


The interface is pretty much exactly what I had in mind for a similar 
system.

What do the statically defined assemblies do - do they call into the 
IronPython engine - and if so, for IronPython 1 or 2? If not then are 
you just compiling Python to static assemblies?

To my mind the former is more interesting than the latter... (Although 
both are interesting of course...)

Michael
http://www.manning.com/foord


Curt Hagenlocher wrote:
> After a bit of spare-time hacking this weekend, I've got a 
> "proof-of-concept" program that takes a Python class and exports it as 
> a (statically-defined) assembly.  It uses Pythonic function 
> annotations to signal attributes and input and output types to the 
> wrapper generator.  You end up with something like this
>  
> def Test(object):
>     @ClrAttribute(Xunit.FactAttribute)
>     def WorthlessTest(self):
>         Xunit.Assert.Equal[type(1)](1, 1)
>     
>     @ClrAccepts(System.String, System.Int32)
>     @ClrReturns(System.Int32)
>     def CalculateValue(self, s, i):
>         return len(s) + i
>  
> The program takes this source and spits out a DLL containing the class 
> "Test" which implements "WorthlessTest" and "CalculateValue".  The 
> class itself contains a reference to the actual Python object, and 
> each of the public functions simply delegates to the Pythonic 
> implementation.
>  
> I'm still working on cleaning up the source a little before releasing 
> it, but was wondering if anyone had some feedback on the design as 
> described so far.  What should be changed or implemented in order for 
> this to be more useful to you?
>  
> Thanks,
> -Curt
>  
> --
> Curt Hagenlocher
> curt at hagenlocher.org <mailto:curt at hagenlocher.org>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list