views:

1591

answers:

3

Hi,

I would like to give sources for what I'm saying but I just dont have them, it's something I heard.

Once a programming professor told me that some software benchmarking done to .net vs Python in some particular items it gave a relation of 5:8 in favor of .NET . That was his argument in favor of Python not being so much slower than .NET

Here it's the thing, I would like to try IronPython since I could combine the web framework I know the most (asp.net) with the language I like the most (Python) and I was wondering about the speed of programs in asp.net in Python vs the speed of programs in ASP.NET with VB.net or C#. Is there any software benchmarking on this?

Also, shouldnt the speeds of IronPython compared to other .NET languages be similar, since IronPython unlike Python have to compile to the .NET intermediate code? Can someone enlight me on these issues?

Greetings

+5  A: 

Here are two interesting links with comparisons between IronPython, CPython, and C# (among others):

  • CPython vs C# (Mono) benchmarks, based on several programs detailed on the site.
  • CPython vs IronPython benchmarks, based on PyStone and PyBench, for versions 2.6.

So apparently it does along the lines of what your professor told you. But as you know, it depends so much on what you are using.

The difference is mainly due to the dynamic nature of the objects used in Python, whereas C# is strongly typed. So IronPython uses one more level (the DLR - Dynamic Language Runtime) on top of what C# is run from (the CLR - the Common Language Runtime), to resolve this difference.

I usually hate to cite Wikipedia articles, but this is a good starting point: http://en.wikipedia.org/wiki/Dynamic_Language_Runtime

Now to come back to your project, the performances will probably be more dependent on your algorithms/heuristics - how you query a database for example - than on the language. If you are familiar with a web framework and are happy with it, it's a good idea to stick with the same environment rather than gain a possible few percents on something you'll have to tame first. It wouldn't be the same if the application was CPU-intensive of course.

RedGlyph
"C# is strongly typed". Do you mean "statically typed"? Or "strongly typed variable declarations"? Python's type binding is quite strong, but it's variables are dynamic.
S.Lott
I mean strongly typed declarations, which of course allows the compiler to get much closer to the final result in the assemblies than what Python can achieve because of its duck typing.
RedGlyph
Sadly the CPython vs. IronPython benchmarks were run either only reporting one round, or in some cases definitely only *running* one round, which makes them very questionable.
Nick Bastin
It gives a general idea, I don't think it would be sensible to extract a global performance figure for such different applications (which is reflected in the discrepancy of their results). Comparing a few benchmarks related to what the OP really needs would be more appropriate, that's what S.Lott stated in his post. But that's more work :-)
RedGlyph
@S.Lott - in the .NET world people seem intent on referring to static typing as "strong typing". I'm not sure why they do that.
orip
+1  A: 

You could enable .net tracing, which outputs timing information at the bottom of the page. Make an app in C#/.Net and an app using Python and look at the differences in timing. That will give you a definitive answer.

In all honesty I think you're better off just using C#, it's "faster" to develop since the VS environment is there for you and it's going to run faster since it doesn't have to use the dynamic language runtime.

Steven Graham
I know, but what appeals me from Python it is it allows you to write less code, besides I think you can't do this in C# without rewriting (though not completely sure) http://www.ironpythonresource.com/post/2008/08/23/IronPython-Dynamically-creating-objects-and-binding-them-to-a-form.aspx
Pablo
Perhaps in C# 4.0 with the new features?
Pablo
As a dynamically typed language Python is generally faster to develop with than C#. If you use an IDE like Wing, with intellisense etc for Python, then you get a lot of what Visual Studio has to offer for C#.
fuzzyman
yes, in web development is hard to come back to a statically typed language when you tried a dynamically typed one. But I think I've read C# 4.0 will have dynamic type capabilities
Pablo
oh, I just realized I read your IronPython book. Any plans for a spanish release because if there is one, I can't find it :)
Pablo
A: 

IronPython will be considerably slower than C#. You could think of the comparison as very roughly between CPython and C, but with the gap somewhat smaller.