mike watkins dot ca : Why Python 3?

Why Python 3?

Now that Python 3.0 has been released I suppose it's not surprising to see some strains of "why Python 3" floating around the blogosphere. I'd like comment on this from the perspective of a Python language user (which I am), rather than as a Python language developer (which I am not).

Jesse Noller laments for a lack of time, and perhaps patience, to respond to some of the not well founded criticisms of the new language branch. Here's one contribution Jesse, and while I'd rather not write about something so pedestrian as raw performance, as the subject has come up in recent discussions, it seems appropriate and necessary to do so.

What I'd rather do is muse about the future, as Chad Whitacre writes in "Why is Python 3 important?" where he proclaims "Python 2 is great; Python 3 is masterful". Perhaps I'm not fully qualified to speak to this, but I know what I like.

In other lives and for equal parts recreation and frustration I write a fair amount of English prose. When I have time to, I even try to make my writing somewhat artful. Never will I tire of the flexibility of the English language to be bent in oh so many ways to deliver a message.

I would not wish to compare the English language to Python, as there is certainly more than one way to express a thought in regular prose while there's only one way to do it is a key design objective for Python.

What I get out of writing prose is appreciation for composition and design, whether I wrote the piece or not. One doesn't have to be a CS graduate to appreciate clean design in a language, any more than you don't have to be an engineer to appreciate a fine bicycle.

As I've worked with Python 3 over the past few months I've come to appreciate and understand most of the design choices the developers have made. Like a well structured essay, Python 3 gets its point across clearly and with a minimum of fuss.

Aside from a general tightening up of the language and standard library, in particular I greatly appreciate the vast improvements made to ... strings. Working with Unicode is now a pleasure, and largely automatic. For many it will just work, something that can not be easily said about the prior Unicode implementation. That alone is worth the price of admission.

Overall Experience with Python 3: Positive

I can't recall if I felt conflicted about Python 3 before I took a serious look at it, but if I did, I certainly do not now feel that way after having spent some quality time with Python 3 over the past several months.

In conjunction with helping do some quality assurance testing on the QP web framework and related packages, I ported my company's library and one key application to support simultaneously 2.6 and 3.0. In making this transition I've had broad exposure to most of the changes in Python. I don't recall cursing too much through the experience, although truth be told I did initially miss __cmp__. Reading the What's New in Python 3.0 page, many times, is certainly a prerequisite to any porting adventure. One of the authors of QP and related packages recently posted a summary of the steps they took to achieve dual compatibility with Python 2 and 3.

The most significant syntax change that proved problematic was the syntax change for metaclass use. David Binger of the MEMS and Nanotechnology Exchange had come up with a novel workaround that I'd never have come up with myself, even if I did understand it, but it still hurt my brain. Luckily a little naive web searching and some playtime in the interpreter brought me to a neater solution which even I understand.

The QP 2.1 release experience seems to demonstrate that well crafted packages should not be too difficult to port. Some applications and packages might even make sense to support, against the official recommendations, both Python 2.x and 3.x off the same code base.