IronPython

From Wikipedia, the free encyclopedia
Jump to: navigation, search
IronPython
Developer(s) Dino Viehland, Microsoft
Stable release 2.6.1 (Final) / April 12, 2010; 4 months ago (2010-04-12)
Preview release 2.7 alpha for .NET 4.0 / July 16, 2010; 52 days ago (2010-07-16)
Written in C#
Platform .NET Framework, Mono
Type Python Programming Language Implementation
License Apache License, v2.0
Website http://ironpython.codeplex.com/

IronPython is an implementation of the Python programming language targeting the .NET Framework and Mono, created by Dino Viehland. Jim Hugunin started the project and worked on Version 1.0, which released on September 5, 2006.[1] Version 2.0 was released on December 10, 2008.[2]

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.[citation needed] 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.

Contents

[edit] Status and roadmap

Release 2.0, released on December 10, 2008, targets CPython 2.5.

Release 2.6, released on December 11, 2009, targets CPython 2.6. The first alpha was released on March 26, 2009. IronPython 2.6 Alpha 1 release notes.

There are some differences between the Python reference implementation (CPython) and IronPython.[3] Some projects built on top of IronPython are known not to work under CPython.[4] Conversely, CPython applications that depend on extensions to the language that are implemented in C (e.g. NumPy) are not compatible with IronPython,[5] although a commercially-supported open source project to address this is underway.[6]

[edit] License

IronPython is released under the Microsoft Public License,[7] which the Open Source Initiative has confirmed complies with their definition of open source. Until version 0.6 IronPython was released under the Common Public License.[8] 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.[9] The license was changed to the Microsoft Public License with the 2.0 alpha release.

[edit] 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.[10]

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.

[edit] 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")

[edit] Performance

The performance characteristics of IronPython compared to CPython, the reference implementation of Python, depends on the exact benchmark used. IronPython performs better than CPython on the PyStone benchmark but worse on other benchmarks.[11]

[edit] See also

[edit] References

  1. ^ "Jim Hugunin's blog: IronPython 1.0 released today!". 2006-09-05. http://blogs.msdn.com/hugunin/archive/2006/09/05/741605.aspx. Retrieved 2006-12-14. 
  2. ^ "Release dates for ironpython". 2008-12-10. http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=8365. Retrieved 2009-01-25. 
  3. ^ "Differences between IronPython 1.0 and CPython 2.4.3". Microsoft. 2007-12-18. http://www.codeplex.com/IronPython/Wiki/View.aspx?title=Differences&referringTitle=Home. Retrieved 2008-02-09. 
  4. ^ Foord, Michael. "New Project: Implementing .NET Libraries in Pure Python". http://lists.ironpython.com/pipermail/users-ironpython.com/2008-January/006297.html. Retrieved 2008-02-09. 
  5. ^ Eby, Phillip. "Children of a Lesser Python". http://dirtsimple.org/2005/10/children-of-lesser-python.html. Retrieved 2008-07-09. 
  6. ^ "Ironclad". http://www.resolversystems.com/documentation/index.php/Ironclad. Retrieved 2008-07-09. 
  7. ^ "Microsoft permissive license". April 28, 2007. http://www.codeplex.com/IronPython/Project/License.aspx?LicenseHistoryId=2866. Retrieved 2007-05-13. 
  8. ^ "Original IronPython homepage". July 28, 2004. http://www.ironpython.com/old.html. Retrieved 2007-05-13. 
  9. ^ "Shared Source License for IronPython". April 28, 2006. http://www.codeplex.com/IronPython/Project/License.aspx?LicenseHistoryId=129. Retrieved 2007-05-13. 
  10. ^ "Using .NET objects from IronPython in Resolver One". http://www.resolversystems.com/documentation/index.php/Dot_Net_Objects_in_the_Grid. Retrieved 2008-11-18. 
  11. ^ "IronPython Performance Report". http://ironpython.codeplex.com/Wiki/View.aspx?title=IP26RC1VsCPy26Perf&referringTitle=Home. Retrieved 2009-10-05. 

[edit] External links

Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox
Print/export
Languages