Portrait of Edd Dumbill, taken by Giles Turnbull

Subscribe to updates

Feed icon Atom or RSS

or get email updates

What I make

a conference management web application

XTech Conference
a European web technology conference

IronPython released as open source

IronPython is an implementation of Python targeted at the ECMA CLR, which runs in .NET and Mono. I first heard of it in reports from Pycon 2004, and was pretty excited at the time. Not least because IronPython even claims to run faster than the C implementation. Before I met Mono/C# I was doing most of my prototyping in Python, so it's been a personal goal to get the two unified. Unfortunately, IronPython remained under wraps.

Until now, that is. At his talk at OSCON this afternoon IronPython's author Jim Hugunin announced that his work is now available as open source. Hugunin says the work is currently pre-alpha, but I imagine as soon as people get their hands on it this will improve.

I downloaded IronPython and gave it a quick spin against Mono. Here's a simple Gtk# Hello World program:

  import Gtk

  def delete_event (o, args):
    Gtk.Application.Quit ()

  def say_hi (o, args):
    print "Hello, World!" 

  Gtk.Application.Init ()
  w = Gtk.Window ("Hello, Gtk# World")
  w.DeleteEvent += delete_event

  b = Gtk.Button ("Say Hello")
  b.Clicked += say_hi
  w.Add (b)
  w.ShowAll ()
  Gtk.Application.Run ()

This should work just fine with Mono 1.0 and the IronPython 0.6 download, and should look a bit like this:

Gtk# screenshot, run on IronPython

Hugunin's demonstration was pretty cool, particularly the demo of the Python interactive console being able to change parts of an application while it is running. IronPython's written in C#, after 3 prototypes that were written first in Python. I suspect that will be a common and valuable usage pattern for other people too.

Before IronPython, the common wisdom was that it was difficult to make dynamic languages perform well on the CLR. Hugunin mentioned some keys to getting it fast: using native CLR constructs where possible, creating fast paths (in IL) for common cases, and making lots of measurements and optimisations.

Performance-wise, IronPython shows up some stuff that Mono needs to do to make it faster. According to Hugunin's tests with the "parrotbench" benchmarks, IronPython on .NET runs faster than Mono. That's not to say that the Mono performance is bad: it still stands up well against .NET and Python 2.3. Apparently one place that Mono needs to make improvements is in the handling of exceptions, which seems significantly slower. The conclusion of the benchmarks is that IronPython/.NET is 4% slower than Python 2.3, which is more or less negligible, especially as benchmarks aren't always typical of normal programs. (The previous benchmark giving the radically faster figures was pystone, which everyone admits isn't a great measure.)

I'm very excited about IronPython. Now Mono will have a decent selection of languages: C# (or Java, via IKVM) for large scale systems, and Python for scripting. And even better, because it's the same virtual machine all these languages can reuse class libraries from each other.

blog comments powered by Disqus

You are reading the weblog of Edd Dumbill, writer, programmer, entrepreneur and free software advocate.
Copyright © 2000-2012 Edd Dumbill