IronPython
Encyclopedia
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. Thereafter, it was maintained by a small team at Microsoft until the 2.7 Beta 1 release. Version 2.0 was released on December 10, 2008.
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
(DLR), 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 trunk builds of Mono. The DLR can also be used as a library on older CLI implementations.
. IronPython 2.0.3 is only compatible up to .NET Framework 3.5.
Release 2.6, released on December 11, 2009, and updated on April 12, 2010, targets CPython 2.6. IronPython 2.6.1 versions is binary compatible only with .NET Framework 4.0. IronPython 2.6.1 must be compiled from sources to run on .NET Framework 3.5. Iron Python 2.6.2, released on October 21, 2010, is binary compatible with both .NET Framework 4.0 and .NET Framework 3.5.
Release 2.7 was released on March 12, 2011 and it targets CPython 2.7.
) 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 (e.g. NumPy) are not compatible with IronPython, although a commercially-supported open source project to address this is underway.
engine. IronPython scripts are passed like simple client-side Javascript-scripts in
markup.
The technology behind this is called Gestalt.
The same works for IronRuby
.
. 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 Open Source Initiative
has confirmed complies with their definition
of open source
. The latest versions are released under the Apache License 2.0.
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.
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.
on most of the PyStone benchmarks but better on other benchmarks.
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
targeting the .NET Framework
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
and Mono
Mono (software)
Mono, pronounced , is a free and open source project led by Xamarin to create an Ecma standard compliant .NET-compatible set of tools including, among others, a C# compiler and a Common Language Runtime....
. Jim Hugunin
Jim Hugunin
Jim Hugunin is a software programmer who created the Python programming language extension Numeric , and later created Python implementations for the Java Platform and for Microsoft .NET platform ; he has also co-designed the AspectJ extension for the Java programming language...
created the project and actively contributed to it up until Version 1.0 which was released on September 5, 2006. Thereafter, it was maintained by a small team at Microsoft until the 2.7 Beta 1 release. Version 2.0 was released on December 10, 2008.
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
Dynamic Language Runtime
The Dynamic Language Runtime from Microsoft is an ongoing effort to bring a set of services that run on top of the Common Language Runtime and provides language services for several different dynamic languages...
(DLR), a library running on top of the Common Language Infrastructure
Common Language Infrastructure
The Common Language Infrastructure is an open specification developed by Microsoft and standardized by ISO and ECMA that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework and the free and open source implementations Mono and Portable.NET...
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 trunk builds of Mono. The DLR can also be used as a library on older CLI implementations.
Status and roadmap
Release 2.0, released on December 10, 2008, and updated as 2.0.3 on October 23, 2009, targets CPython 2.5CPython
CPython is the default, most-widely used implementation of the Python programming language. It is written in C. In addition to CPython, there are two other production-quality Python implementations: Jython, written in Java, and IronPython, which is written for the Common Language Runtime. There...
. IronPython 2.0.3 is only compatible up to .NET Framework 3.5.
Release 2.6, released on December 11, 2009, and updated on April 12, 2010, targets CPython 2.6. IronPython 2.6.1 versions is binary compatible only with .NET Framework 4.0. IronPython 2.6.1 must be compiled from sources to run on .NET Framework 3.5. Iron Python 2.6.2, released on October 21, 2010, is binary compatible with both .NET Framework 4.0 and .NET Framework 3.5.
Release 2.7 was released on March 12, 2011 and it targets CPython 2.7.
Differences with CPython
There are some differences between the Python reference implementation (CPythonCPython
CPython is the default, most-widely used implementation of the Python programming language. It is written in C. In addition to CPython, there are two other production-quality Python implementations: Jython, written in Java, and IronPython, which is written for the Common Language Runtime. There...
) 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 (e.g. NumPy) are not compatible with IronPython, although a commercially-supported open source project to address this is underway.
Silverlight
IronPython is supported on Silverlight. It can be used as a scripting engine in the browser just like the JavaScriptJavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....
engine. IronPython scripts are passed like simple client-side Javascript-scripts in
-tags. It is then also possible to modify embedded XAMLXAML
Extensible Application Markup Language is a declarative XML-based language created by Microsoft used for initializing structured values and objects. It is available under Microsoft's Open Specification Promise...
markup.
The technology behind this is called Gestalt.
The same works for IronRuby
IronRuby
IronRuby is an implementation of the Ruby programming language targeting Microsoft .NET framework. It 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,...
.
License
Until version 0.6 IronPython was released under the Common Public LicenseCommon Public License
In computing, the CPL is a free software / open-source software license published by IBM. The Free Software Foundation and Open Source Initiative have approved the license terms of the CPL....
. Following recruitment of the project lead in August 2004, IronPython was made available as part of Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
's Shared Source
Shared source
Shared source is an umbrella term covering some of Microsoft's legal mechanisms for software source code distribution. Microsoft's Shared Source Initiative, launched in May 2001, includes a spectrum of technologies and licenses...
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 Open Source Initiative
Open Source Initiative
The Open Source Initiative is an organization dedicated to promoting open source software.The organization was founded in February 1998, by Bruce Perens and Eric S. Raymond, prompted by Netscape Communications Corporation publishing the source code for its flagship Netscape Communicator product...
has confirmed complies with their definition
Open Source Definition
The Open Source Definition is a document published by the Open Source Initiative, to determine whether or not a software license can be labeled with the open-source certification mark....
of open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...
. The latest versions are released under 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
Reflection (computer science)
In computer science, reflection is the process by which a computer program can observe and modify its own structure and behavior at runtime....
. 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.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.
Performance
The performance characteristics of IronPython compared to CPython, the reference implementation of Python, depends on the exact benchmark used. IronPython performs worse than CPythonCPython
CPython is the default, most-widely used implementation of the Python programming language. It is written in C. In addition to CPython, there are two other production-quality Python implementations: Jython, written in Java, and IronPython, which is written for the Common Language Runtime. There...
on most of the PyStone benchmarks but better on other benchmarks.
See also
- Boo, a language for the .NET Framework.NET FrameworkThe .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
and MonoMono (software)Mono, pronounced , is a free and open source project led by Xamarin to create an Ecma standard compliant .NET-compatible set of tools including, among others, a C# compiler and a Common Language Runtime....
with Python-inspired syntax and features borrowed from C# and RubyRuby (programming language)Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...
. - CobraCobra (programming language from Cobra Language LLC)Cobra is an object-oriented programming language produced by Cobra Language LLC. Cobra is designed by Chuck Esterbrook, and runs on the Microsoft .NET and Mono platforms. It is strongly influenced by Python, C#, Eiffel, Objective-C, and other programming languages. It supports both static and...
- IronLispIronLispIronLisp was an implementation of the Lisp programming language targeting the Microsoft .NET framework. It was announced by Xacc.ide on July 23, 2007. It was superseded by IronScheme November 5, 2007 while still in beta. No further development will take place on IronLisp.IronLisp Beta versions have...
- IronRubyIronRubyIronRuby is an implementation of the Ruby programming language targeting Microsoft .NET framework. It 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,...
- IronSchemeIronSchemeIronScheme is an implementation of the Scheme programming language targeting the Microsoft .NET framework. IronScheme is a complete rewrite of IronLisp, incorporating lessons learnt while developing IronLisp....
- JythonJythonJython, successor of JPython, is an implementation of the Python programming language written in Java.-Overview:Jython programs can seamlessly import and use any Java class. Except for some standard modules, Jython programs use Java classes instead of Python modules...
- an implementation of PythonPython (programming language)Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
for the Java Virtual MachineJava Virtual MachineA Java virtual machine is a virtual machine capable of executing Java bytecode. It is the code execution component of the Java software platform. Sun Microsystems stated that there are over 4.5 billion JVM-enabled devices.-Overview:...
. - Unladen SwallowUnladen SwallowUnladen Swallow was an optimization branch of CPython, intended to be fully compatible and significantly faster. It aimed to achieve its goals by supplementing CPython's custom virtual machine with a JIT built using LLVM. The project had stated a goal of a five-times speed improvement over CPython...
- An optimization branch of CPython supported by GoogleGoogleGoogle Inc. is an American multinational public corporation invested in Internet search, cloud computing, and advertising technologies. Google hosts and develops a number of Internet-based services and products, and generates profit primarily from advertising through its AdWords program...
and intended to be fully compatible and significantly faster. - pypyPyPyPyPy is a Python interpreter and JIT compiler. PyPy focuses on speed, efficiency and 100% compatibility with the original CPython interpreter.- Details and motivation :...
- a self-hosting interpreter for the Python programming language.
External links
- Official website
- IronPython on Codeplex
- IronPython in Action - first English book on IronPython with foreword by Jim Hugunin