Developers prepare for Python breakage

Release manager Anthony Baxter has warned that the new version of Python will bring changes to some fundamental elements of the programming language
Written by Angus Kidman, Contributor

The launch of version 3.0 of Python, expected within the next year, will see major changes to some fundamental elements of the programming language, release manager Anthony Baxter explained in a keynote speech at linux.conf.au in Melbourne.

Python is used extensively by Google for many of its products, including the popular YouTube video-sharing site.

"3.0 is also known as the release where we break all your code but we're doing it for a good reason," Baxter said. "Python is 16 years old. Like all 16-year-olds, it's got some really annoying features."

"Pretty much every program will need changes," Baxter said, but he stressed that the shift would be some time in coming. "2.x is also not going away. There is going to be a 2.6, it'll be out at about the same time as 3.0. We're not expecting everyone to turn around and rewrite their massive code bases the day after 3.0 comes out — that would be very foolish. We'll keep maintaining [the 2.x series] as long as there is interest and need."

Both the 2.6 and 3.0 releases are due to appear in late 2008 or early 2009. "I really do think it'll be early next year before it's out. I think there's so much work to bed it down," Baxter said.

When they do come, those alterations will present a big challenge to a company such as Google, where Baxter has his day job. Around 15 percent of the search giant's total code base is written in Python. "We get a lot of coders. Obviously I can't say how many, but it's a lot," Baxter noted.

The increasingly complexity of the language has made it difficult for Google's developer teams to work with multiple languages. "[Python] is used for a lot of the core glue. People are having to bounce between Java and Python. They need to context switch. In that case, a lighter-weight language is a huge bonus. For these guys, simpler is much, much better."

One of the most notable changes is turning the "print" statement, used for all kinds of information output, into a function. "Currently print has awful syntax for doing all sorts of things," Baxter said.

"The other one that's going to break a lot of code really subtly is that Unicode is now the default. There's a real shambles in Python at the moment when it comes to mixing Unicode and non-Unicode strings."

Other alterations, such as altering models used for division and switching the symbols for "not equal" from "<>" to "!=", have long been discussed in the Python community but have been held back because of fears over backward compatibility. With the shift to 3.0, the view is "what the hell, we're breaking the code anyway, let's fix it", Baxter said.

"It's a good thing, backward compatibility, but you have a cost. There's always a cost when you make a decision to keep around the old rubbish. It hurts."

To minimise problems with changes, Python 2.6 is also being altered to warn developers of constructs that might prove problematic when they move to 3.0. "In 2.6 we've added a bunch of warnings, and there's going to be more of these going through," Baxter said.

Editorial standards