Saturday, December 6, 2008

Changes in Python 3.0

A new version of Python, 3.0, has been recently released. It has a a lot of changes, and for a lot of people, it has more changes than desirable, so don't rush to instal it, keep on reading and learn before deciding.

Most changes in Pyhton until now have been retrocompatibles. This implied that, unless we had used an obscure quirk of a command that got corrected in later versions, we didn't had much problem while changing versions. Most problems usually had to do with the use of third party libraries that were only compatible with a specific version of Python.

However, while releasing version 2.6 we were informed that it was a transition release, and that they were going to start working on the new version 3.0. We were also told that this new version wasn't retrocompatible, it was going to be a rewriting and general reordering. They even offered in 2.6 some glimpses of things to come in 3.0, that's why they called it a transition release.

Looking through the list of changes in this new release 3.0, you can see that it's really a long list, including changes in command syntax, in command behavior, in data types, in library names and even in command names. This means that before using our old programs in 3.0 we'll have to upgrade them. Luckily, there's an automated toll called 2to3 that does most changes for us, so we'll have to do little else to make most programs work.

An interesting data is that now efforts in development of the language are split between a future 3.1 release for the ones that went through 3.0 and a future 2.7 release for the ones that didn't. 2.7 is supposed to update the language without breaking most of retrocompatiblity.

¿what to do then? That depends in what we have already developed. If it relies heavily in a library that's still not available for 3.0 then don't change, wait for it to release. If it's a big project and even with 2to3 the conversion gets tricky, don't change. If you don't have any of this problems, go to 3.0, it's the road towards a better, cleaner Python.

And as always in this kind of problems, mounting a virtual machine to test changes can save us a lot of headaches.

No comments: