IronPython


IronPython is an implementation of the Python programming language targeting the.NET Framework and Mono. Jim Hugunin created the project and actively contributed to it up until Version 1.0 which was released on September 5, 2006. IronPython 2.0 was released on December 10, 2008. After version 1.0 it was maintained by a small team at Microsoft until the 2.7 Beta 1 release. Microsoft abandoned IronPython in late 2010, after which Hugunin left to work at Google. The project is currently maintained by a group of volunteers at GitHub. It is free and open-source software, and can be implemented with Python Tools for Visual Studio, which is a free and open-source extension for Microsoft's Visual Studio IDE.
IronPython is written entirely in C#, although some of its code is automatically generated by a code generator written in Python.
IronPython is implemented on top of the Dynamic Language Runtime, a library running on top of the Common Language Infrastructure that provides dynamic typing and dynamic method dispatch, among other things, for dynamic languages. The DLR is part of the.NET Framework 4.0 and is also a part of Mono since version 2.4 from 2009. The DLR can also be used as a library on older CLI implementations.

Status and roadmap

There are some differences between the Python reference implementation CPython and IronPython. Some projects built on top of IronPython are known not to work under CPython. Conversely, CPython applications that depend on extensions to the language that are implemented in C are not compatible with IronPython
, unless they are implemented in a.NET interop. For example, NumPy was wrapped by Microsoft in 2011, allowing code and libraries dependent on it to be run directly from.NET Framework.

Silverlight

IronPython is supported on Silverlight. It can be used as a scripting engine in the browser just like the JavaScript engine. IronPython scripts are passed like simple client-side JavaScript scripts in
//Client-side script passed to IronPython and Silverlight.


The same works for IronRuby.

License

Until version 0.6, IronPython was released under the terms of Common Public License. Following recruitment of the project lead in August 2004, IronPython was made available as part of Microsoft's Shared Source initiative. This license is not OSI-approved but the authors claim it meets the open-source definition. With the 2.0 alpha release, the license was changed to the Microsoft Public License, which the OSI has approved. The latest versions are released under the terms of the Apache License 2.0.

Interface extensibility

One of IronPython's key advantages is in its function as an extensibility layer to application frameworks written in a.NET language. It is relatively simple to integrate an IronPython interpreter into an existing.NET application framework. Once in place, downstream developers can use scripts written in IronPython that interact with.NET objects in the framework, thereby extending the functionality in the framework's interface, without having to change any of the framework's code base.
IronPython makes extensive use of reflection. When passed in a reference to a.NET object, it will automatically import the types and methods available to that object. This results in a highly intuitive experience when working with.NET objects from within an IronPython script.

Examples

The following IronPython script manipulates.NET Framework objects. This script can be supplied by a third-party client-side application developer and passed into the server-side framework through an interface. Note that neither the interface, nor the server-side code is modified to support the analytics required by the client application.

from BookService import BookDictionary
booksWrittenByBookerPrizeWinners =

In this case, assume that the.NET Framework implements a class, BookDictionary, in a module called BookService, and publishes an interface into which IronPython scripts can be sent and executed.
This script, when sent to that interface, will iterate over the entire list of books maintained by the framework, and pick out those written by Booker Prize-winning authors.
What's interesting is that the responsibility for writing the actual analytics reside with the client-side developer. The demands on the server-side developer are minimal, essentially just providing access to the data maintained by the server. This design pattern greatly simplifies the deployment and maintenance of complex application frameworks.
The following script uses the.NET Framework to create a simple Hello World message.

import clr
clr.AddReference
from System.Windows.Forms import MessageBox
MessageBox.Show

Performance

The performance characteristics of IronPython compared to CPython, the reference implementation of Python, depends on the exact benchmark used. IronPython performs worse than CPython on most benchmarks taken with the PyStone script but better on other benchmarks.
IronPython may perform better in Python programs that use threads or multiple cores, as it has a JIT compiler, and also because it doesn't have the Global Interpreter Lock.