Super-Fast Python Implementation for .NET and Mono 54
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.'"
Re:Well, that's great and all (Score:2, Informative)
Re:Compiled Python (Score:5, Informative)
Re:Next Question (Score:5, Informative)
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
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
Lisp (was Re:stuck?) (Score:3, Informative)
Re:not released (Score:4, Informative)
Psyco (Score:4, Informative)
I don't know about pystone in particular, but Psyco [sf.net] (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 [python.org]!
Re:Psyco (Score:3, Informative)
"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.
Re:What changed? (Score:2, Informative)
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.