views:

3270

answers:

6

No doubt most people have read all about the various incompatible changes that are going into Python 3, so on a question of just performance, how does python 3 compare to python 2.x?

+7  A: 

I'd say any difference will be below trivial. For example, looping over a list will be the exact same.

The idea behind Python 3 is to clean up the language syntax itself - remove ambigious stuff like except Exception1, Exception2, cleanup the standard modules (no urllib, urllib2, httplib etc).

There really isn't much you can do to improve it's performance, although I imagine stuff like the garbage collection and memory management code will have had some tweaks, but it's not going to be a "wow, my database statistic generation code completes in half the time!" improvement - that's something you get by improving the code, rather than the language!

Really, performance of the language is irrelevant - all interpreted languages basically function at the same speed. Why I find Python "faster" is all the built-in moudles, and the nice-to-write syntax - something that has been improved in Python3, so I guess in those terms, yes, python3's performance is better then python2.x..

dbr
"all interpreted languages basically function at the same speed" is very much not true. Interpreted code paths can be compiled down to native code, see the recent Javascript VM competitors.
James Baker
that means nothing about the language, but the compilers written for it. You *could* have a python compiler and it'd be roughly as fast as a javascript one.
gbjbaanb
A: 

I don't if it faster now, but I have to expect that it eventually will be because that is where new performance work will happen and not all of that will be backported.

indentation
+23  A: 

3.0 is slower than 2.5 on official benchmarks. From "What’s New in Python 3.0":

The net result of the 3.0 generalizations is that Python 3.0 runs the pystone benchmark around 10% slower than Python 2.5. Most likely the biggest cause is the removal of special-casing for small integers. There’s room for improvement, but it will happen after 3.0 is released!

Constantin
+2  A: 

Unless there are plans for a new VM of some kind (and I haven't heard of any such plans), there is all the reason to believe that in the long run the performance of Py3K will, at least asymptotically, equal that of 2.5

It may take a few months, but will eventually happen, as nothing in the new features of Py3k is inherently less performant.

To conclude, I don't think there's place to worry about it. Neither to hope for a major improvement of some kind.

Eli Bendersky
(Update 30.03.2010): This answer isn't very relevant today, since unladen-swallow is going to be merged into Python 3 and provide noticeable speedups. To be fair, this *is* a new VM :-)
Eli Bendersky
+4  A: 

I think ultimately it is too early to make that kind of comparison just yet. Wait until it is out of beta before benchmarking it. The interpreter will probably be polished enormously before the release but overall i think for most uses the performance would be comparable and if you are running a really speed conscious app is python really the right language to be using?

PixelSmack
+3  A: 

The IO library has been completely redesigned, and the new implementation is in pure Python. Whilst this is a functional improvement, it is at present much slower. Work is afoot to rewrite the bulk of the new system in C. For details see these bug reports.

jlarcombe