IronPython
Designed by | Jim Hugunin |
---|---|
Developer | Dino Viehland |
First appeared | September 5, 2006[1] |
Stable release | 2.7.5 / December 6, 2014[2] |
Implementation language | C# |
Platform | .NET Framework, Mono |
License | Apache License, v2.0 |
Website |
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.[3] Thereafter, it was maintained by a small team at Microsoft until the 2.7 Beta 1 release; Microsoft abandoned IronPython (and its sister project IronRuby) in late 2010, after which Hugunin left to work at Google.[4] IronPython 2.0 was released on December 10, 2008.[5] The project is currently maintained by a group of volunteers at Microsoft's CodePlex open-source repository. 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 free, isolated, and commercial versions of Microsoft's Visual Studio IDE.[6][7]
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.[8] 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.5.[9] 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.[10] 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.[11]
- Release 2.7.1 was released on October 21, 2011 and it targets CPython 2.7.[12]
- Release 2.7.2.1 was released on March 13, 2012. It enables support for ZIP file format libraries, SQLite, and compiled executables.[13]
- Release 2.7.4 was released on September 7, 2013.[14]
- Release 2.7.5 was released on December 6, 2014 and mostly consists of bug fixes.[15]
Differences with CPython
There are some differences between the Python reference implementation CPython and IronPython.[16] Some projects built on top of IronPython are known not to work under CPython.[17] Conversely, CPython applications that depend on extensions to the language that are implemented in C (e.g. NumPy) are not compatible with IronPython.[18]
Silverlight
IronPython is supported on Silverlight. It can be used as a scripting engine in the browser just like the JavaScript engine.[19] IronPython scripts are passed like simple client-side Javascript-scripts in <script>
-tags. It is then also possible to modify embedded XAML markup.
The technology behind this is called Gestalt.
//DLR initiation script.
<script src="http://gestalt.ironpython.net/dlr-latest.js" type="text/javascript"></script>
//Client-side script passed to IronPython and Silverlight.
<script type="text/python">
window.Alert("Hello from Python")
</script>
The same works for IronRuby.
License
Until version 0.6 IronPython was released under the Common Public License.[20] 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.[21] With the 2.0 alpha release the license was changed to the Microsoft Public License,[22] 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.
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.[23]
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 = [book.Title for book in BookDictionary.GetAllBooks()
if "Booker Prize" in book.Author.MajorAwards]
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("System.Windows.Forms")
from System.Windows.Forms import MessageBox
MessageBox.Show("Hello World")
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.[24] IronPython may perform better in Python programs that use threads or multiple cores, as it has a JIT, and also because it doesn't have the Global Interpreter Lock.[25][26]
See also
- Boo, a language for the .NET Framework and Mono with Python-inspired syntax and features borrowed from C# and Ruby.
- Cobra
- IronLisp
- IronRuby
- IronScheme
- Jython - an implementation of Python for the Java Virtual Machine.
- Cython
- pypy - a self-hosting interpreter for the Python programming language.
- Tao Framework
- Unladen Swallow - A (now-defunct) branch of CPython that aimed to provide superior performance using an LLVM-based just-in-time compiler.
References
- ↑ http://ironpython.codeplex.com/releases/view/423
- ↑ http://blog.ironpython.net/2014/12/ironpython-275-released.html
- ↑ "Jim Hugunin's blog: IronPython 1.0 released today!". 2006-09-05. Retrieved 2006-12-14.
- ↑ Clarke, Gavin (2010-10-22). "Microsoft cuts loose Iron languages". The Register. Retrieved 2012-04-05.
- ↑ "Release dates for ironpython". 2008-12-10. Retrieved 2009-01-25.
- ↑ "IronPython.net". IronPython.net. Retrieved 2013-07-03.
- ↑ "Python Tools for Visual Studio- Home". Python Tools for Visual Studio. Retrieved 2013-07-03.
- ↑ "Dynamic Language Runtime Overview". Microsoft. Retrieved 2014-04-01.
- ↑ "2.0.3". ironpython.codeplex.com. Retrieved 2010-10-16.
- ↑ "2.6". ironpython.codeplex.com. Retrieved 2010-10-16.
- ↑ "2.7". ironpython.codeplex.com. Retrieved 2011-03-12.
- ↑ "2.7.1". ironpython.codeplex.com. Retrieved 2011-12-30.
- ↑ "2.7.2.1". ironpython.codeplex.com. Retrieved 2012-03-24.
- ↑ "2.7.4". ironpython.codeplex.com. Retrieved 2014-12-07.
- ↑ "2.7.5". ironpython.codeplex.com. Retrieved 2014-12-07.
- ↑ "Differences between IronPython 1.0 and CPython 2.4.3". Microsoft. 2007-12-18. Retrieved 2008-02-09.
- ↑ Foord, Michael. "New Project: Implementing .NET Libraries in Pure Python". Retrieved 2008-02-09.
- ↑ Eby, Phillip. "Children of a Lesser Python". Retrieved 2008-07-09.
- ↑ "IronPython in the web browser - IronPython.net". Retrieved 2014-04-01.
- ↑ "Original IronPython homepage". 2004-07-28. Retrieved 2007-05-13. Archived February 23, 2010, at the Wayback Machine.
- ↑ "Shared Source License for IronPython". 2006-04-28. Retrieved 2007-05-13.
- ↑ "Microsoft permissive license". 2007-04-28. Retrieved 2007-05-13.
- ↑ "Using .NET objects from IronPython in Resolver One". Retrieved 2008-11-18.
- ↑ "IronPython Performance Report". Retrieved 2009-10-05.
- ↑ "IronPython at python.org". python.org. Retrieved 2011-04-04.
IronPython has no GIL and multi-threaded code can use multi core processors.
- ↑ http://jeffknupp.com/blog/2013/06/30/pythons-hardest-problem-revisited/
External links
- Official website
- IronPython on CodePlex
- IronPython in Action - first English book on IronPython with foreword by Jim Hugunin
- The Dynamic Language Runtime and the Iron Languages from The Architecture of Open Source Applications: Volume 2
- IronPython and the Dynamic Language Runtime from MSDN Magazine, 2007
|
|