Slashdot Mirror


Super-Fast Python Implementation for .NET and Mono

Lansdowne writes "Jim Hugunin, the creator of Jython, has released an incredibly fast implementation of Python for Microsoft .NET and Mono called IronPython. Here's his PyCON 2004 presentation, including some benchmarks. He concludes: 'Python is an extremely dynamic language and this offers compelling evidence that other dynamic languages should be able to run well on this platform.'"

21 of 54 comments (clear)

  1. cool stuff by hattmoward · · Score: 4, Interesting

    I'm glad to see more alternative languages for the .NET/Mono platform... If we're gonna get stuck with it, we may as well make the best of it! :) Seeing Python run nice and fast, being a dynamic language and on a VM, is great stuff too.

    1. Re:cool stuff by AJWM · · Score: 2, Interesting

      Cool indeed. But is there a C# compiler targetting Parrot yet? ;-) They look like they're almost both pretty groovy.

      (There's a language I'd like to see on more platforms.)

      --
      -- Alastair
  2. Perhaps he should have waited... by clintp · · Score: 3, Funny

    Maybe he could have gotten in on the Great Parrot/Python Pie-a-Thon. Perhaps an opportunity to plaster both Guido and Dan with a cream pie...

    --
    Get off my lawn.
  3. Well, that's great and all by Anonymous Coward · · Score: 3, Funny

    But Python really hold a candle to PHP or Perl. A language without dollar signs is a day without sunshine.

    Sorry to break it to you.

  4. Next Question by complete+loony · · Score: 2, Interesting

    Is there anything the MONO team can do to improve support for dynamic languages?
    Though this would probably break their binary compatibility with MS's implementation.

    --
    09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
    1. Re:Next Question by Chester+K · · Score: 5, Informative

      Is there anything the MONO team can do to improve support for dynamic languages?

      Mono, today, actually would support dynamic languages better than Microsoft's framework, since they implement the DynamicMethod class, which Microsoft fully documents in their Longhorn SDK documentation, but won't actually be released until .NET 2.0 comes out.

      The DynamicMethod class allows you to load a method into memory for JITting and execution, and preserves the ability for you to unload that code from memory, which you can't do with full-fledged Assemblies, even those generated via Reflection.Emit -- in .NET, once an Assembly is loaded into memory, it stays there until the AppDomain quits.

      --

      NO CARRIER
  5. not released by the+quick+brown+fox · · Score: 5, Insightful

    I usually take "released" to mean there is an implementation that is publicly available. Unless I am somehow just missing it, it doesn't seem to have been released yet...

    1. Re:not released by Phronesis · · Score: 3, Informative

      Indeed, anyone reading the links to IronPython would find that "IronPython is currently an unreleased research prototype."

  6. Re:Compiled Python by FrenZon · · Score: 4, Informative
    I haven't worked with Python yet though I plan to take a look at it soon. I know it is a scripting language but is there a way to compile it into native executable form?
    "You don't need the ability to compile Python to C code if all you want is a stand-alone program that users can download and run without having to install the Python distribution first. There are a number of tools that determine the set of modules required by a program and bind these modules together with a Python binary to produce a single executable..." Read More
  7. What I want to know is... by WTFmonkey · · Score: 3, Funny

    Is is "IronPython," the way we'd usually pronounce it, or do we put a little Rocky Balboa in it and call it the "I- ron Py- thon ?"

  8. Lisp (was Re:stuck?) by Tool+Man · · Score: 3, Informative

    Those Lispy features are a powerful addition, which make it easier for a programmer to get their job done. If you would rather trade those features for performance, consider Fortran instead. It would be more useful if, rather than focus on the leverage of a single-platform solution, the implementors can approach the performance of various Common Lisp implementations. It is true that dynamic languages don't have to be slow; neither do they have to rely on Microsoft's runtime.

  9. Re:stuck? by jsac · · Score: 2, Interesting

    A Python front end for Gcc could be fun. And nearly impossible. I suspect that Python's way too dynamic to be handled by anything but a run-time interpreter.

    --
    "The urge to fly from modern systems, instead of moving through them to even greater, fairer things is, I think, an indi
  10. Psyco by fredrikj · · Score: 3, Informative

    * Fast - IronPython-0.2 is 1.4x faster than Python-2.3 on the standard pystone benchmark.

    I don't know about pystone in particular, but Psyco (a dynamic compiler module that essentially replaces the Python interpreter's inner loop at runtime) tends to make code run much faster than that and can speed up algorithmic code tenfold or more.

    When running with Psyco, quicksort written in Python is actually faster than Python's built-in C mergesort!

    1. Re:Psyco by Anonymous Coward · · Score: 3, Informative

      You got that comparison wrong; mergesort is algorithmically faster than quicksort.

      "Faster" is the wrong word. Mergesort has a lower order of complexity, which means it scales better in suboptimal situations.

      Remember, O(n^2) will always be "faster" than O(m) where n sqrt(m); the complexity of an algorithm is about scalability, not speed.

  11. What changed? by ameoba · · Score: 4, Interesting

    I remember some previous attempt to do Python under .NET that was painfully slow & eventually written off as a failure and blamed on .NET's inability to handle the level of dynamism required to implement Python. What's changed since then?

    Are we looking at some sort of fundamental breakthrough in working with the CLR here or was the problem simply tackled by a more experienced/insightful developer?

    --
    my sig's at the bottom of the page.
    1. Re:What changed? by Anonymous Coward · · Score: 2, Informative

      RTFA.

      Why is IronPython Fast?

      High system performance is the end result of hundreds of small decisions rather than a single large one. Much of IronPython's performance comes from careful consideration of performance in each design choice. I've found that profilers are generally useless for improving the performance of serious applications and that the only good route involves trying a variety of different implementation strategies and comparing their performance in both micro and macro benchmarks. That said, there were a few rules that served me well.

      1. Use native CLR constructs whenever possible. These constructs are all heavily optimized by the underlying runtime engine. Sometimes these constructs will have to be used creatively to properly match Python's dynamic semantics.
      2. Use code generation to produce fast-paths for common cases. This can either be development-time code generation with Python scripts creating C# code or run-time code generation using System.Reflection.Emit to produce IL on the fly.
      3. Include fall-backs to dynamic implementations for less common cases or for cases where Python's semantics requires a fully dynamic implementation.
      4. Finally, test the performance of every CLR construct used and find alternatives when performance is unacceptable. Type.InvokeMember is a great example a a function that must never be used in code that cares about performance.

  12. Incredibly fast? by Fweeky · · Score: 2, Insightful

    A 50% speed boost isn't *that* much; The Python JIT runtime that was on SlashDot just a few weeks ago cited significantly higher increases in performance. Fast, yes, but I'm not amazed or anything here :)

  13. Platform by Hard_Code · · Score: 2, Interesting

    CLR is starting to become a prominent candidate for "open source development platform". Things like IronPython just make this sweeter. One-off interpreters are just a waste of time these days. You can get immense value by creating a generic-enough VM (like Parrot or CLR or JVM) and running <your-favorite-language> on it. Then you get all the benefits of consolidating effort on making the platform better. Next up should be PHP and Ruby (if they haven't already).

    --

    It's 10 PM. Do you know if you're un-American?
  14. Re:Dynamic? by vrt3 · · Score: 2, Interesting

    I can't speak for the term in general, but in Python it means variables can have different types on different times, while still being strongly typed.

    a = 1
    Now a is an integer (actually what happens is this: an integer object is created, with the value 1, and the name a is bound to it)

    a == '1'
    Returns False: objects with different types can not be equal.

    a = '1'
    A new object is created, containing the string '1'. a now binds to that new object.

    a == '1'
    True.

    Somewhat more useful: file objects implement a number of methods. If you write a class that implements those methods (often a subset is enough), you can use it any place where you can use a file object. No need to derive from file class. Of course this doesn't work only for files, it can be used for anything.

    --
    This sig under construction. Please check back later.
  15. Re:stuck? by LWATCDR · · Score: 2, Insightful

    I would not bet that most free software machines do not have a JVM installed. VMs are a great chance for OpenSource to really shine. I used java for an internal program at my company. It is a mission critical app and has worked well for two years now. The best part is that it also runs on Linux. When all of the mission crtical apps are available on Linux then we can move a large section of our office to Linux workstations.
    What most people do not understand is that for the vast majority of business apps the choke point is IO and not CPU speed.

    --
    See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
  16. Re:Dynamic? by Jerf · · Score: 3, Interesting
    That's not the best way of describing how it works.

    In C, a "variable" is a box that contains things. The box is designed to only hold one kind of thing, so an "int" box can't hold a "char *".

    In Python, a "variable" is just a "post-it note" that can be stuck onto a value. The post-it note "a" can be stuck on to anything:
    a = 1
    a = "One"
    a = MyCustomObject()
    Nevertheless, Python is a strongly-typed language; this will raise an error:
    a = 1 + " some"
    (If you're on a Unix system, you most likely have Python installed. Type "python" on the command line and try typing that in.)

    Objects with different types are allowed to be equal, though there is some obvious danger with that. Here's a pathological case:
    class AlwaysEqual:
    def __eq__(self, other):
    return 1

    a = AlwaysEqual()
    a == 1
    a == '1'
    a == None
    This is bad, bad code in real life, but it proves the point.