tags:

views:

112

answers:

3

Hello,

After reading some benchmarks, I noticed that python 3.1 is slower than python 2.6, especially with I/Os.

So I wonder what could be the good reasons to switch to Python 3.x ?

A: 

Largely because of the new I/O library. This, however, has been completely rewritten to C in Python 3.2 and 2.7. I think the performance numbers are pretty close right now if you compare it to 3.2.

edit: I confused the version numbers. Nevermind.

Santa
The I/O library implementation in C was a feature in 3.1, not 3.2 (http://docs.python.org/py3k/whatsnew/3.1.html#optimizations).
Ned Deily
A: 

Go to 3.1. Unless your code is run-once (which at almost never is). 2.6 has no future, and version 3 is the future, unless you are into time travel.

They are working on 3.1 and I can assure you the speeds will soon be up to par, and then exceed 2.6 speeds.

John Smith
Not sure I like the idea of telling him to go 3.x without mentioning the limitations that are still around, like third-party modules and extensions, and the ongoing failure to standardize WSGI for 3.x.
Nicholas Knight
Or 2.7 for compatibility reasons. It's as close as it gets to 3.x.
Santa
A: 

Python 3 does introduce some new language features too. One of my favorite is the new nonlocal keyword, which finally lets you write certain closures nicely, such as:

def getter_setter():
    x = 0
    def getter():
        return x
    def setter(val):
        nonlocal x
        x = val
    return (getter, setter)
Derrick Turk