|
|
Subscribe / Log in / New account

Guido on Python

Benefits for LWN subscribers

The primary benefit from subscribing to LWN is helping to keep us publishing, but, beyond that, subscribers get immediate access to all site content and access to a number of extra site features. Please sign up today!

By Jake Edge
July 22, 2015
EuroPython

Guido van Rossum's EuroPython 2015 keynote was billed as part prepared remarks, part Q&A, but he changed all that when he stepped up on the stage. Instead, it would all be Q&A, but he did prime the pump with some questions (and answers) of his own before taking audience questions. Topics included Python 3 (and 3.5), why there won't be a 2.8, why there are so many open bugs, PyPy, and what he hates about Python.

Django Girls

Van Rossum's first question to himself was about what he thought of Django Girls—the subject of the previous day's keynote. It was a great talk, he said, and he loved the storytelling. There will be none of that in his talk, nor any "pretty slides". He was stunned when he "heard that Ola ... or Ola ... had drawn the squirrels and badgers" for those slides.

Another aspect that he liked was their statement that they didn't know what they were doing. It reminded him of when he started working on Python 25 years ago. He didn't know what he was doing then, either. For example, he had no idea that a programming language needed a community with lots of different roles.

He was also quite impressed by the "strong brand" they have created in one year. "I predict that Ola and Ola, and Django Girls, will go really far."

Python versions

Shifting gears, his next query was on why developers would switch to Python 3. "Why can't you just give up on Python 3?", he asked himself rhetorically. But he is not saying that people should switch. He does want them to, but it is "a lot of hard work that could be spent on other things", such as features for their application or web site. Python 2.7 is not dead yet and will be supported with security fixes and, perhaps, security features for the next five years. Porting to Python 3 is a lot of grunge work, so why bother?

[Guido van Rossum]

Python 3 is a "much better language" than Python 2, for one thing. It is much easier to teach. For example, the Django Girls workshops are all based on Python 3. That wouldn't have been possible if the Django developers hadn't done the grunge work to port the framework. That makes for a more pleasant first experience with the language (and the framework).

It is also getting better over time. There is "lots of cool new stuff" in Python 3.5, for example. Python 2 is a fine language and will remain exactly what it is, which is kind of asymptotically approaching 2.7-perfect, he said. The only way to benefit from all of the work that the core developers are doing is by moving to Python 3.

The perennial question of why not make a Python 2.8 release was next up, though Van Rossum noted that maybe that particular question was getting somewhat dated at this point. Python 2.8 wouldn't solve any of the problems that make people want it. Either it would have no new features, which means there would be no reason not to just stay at 2.7, or the floodgates get opened for backports from Python 3. That would make porting to 2.8 nearly what is needed to port to 3.

Unicode is, of course, the big hurdle to moving to Python 3. But, "enough is enough". So Python 2 is in a state where it will get no new features. That allows the core developers to focus their energy on making Python 3 better.

He then moved on to Python 3.5, which is due in September. He would have trouble choosing a favorite feature from the release because there are "way too many cool things" in it. For example, the performance improvement coming from os.scandir() is great, but it probably won't even be noticed by most. There is a small group of Python users that will be happy to see the new matrix multiplication operator. Numeric packages like NumPy and others will be able to start using it, which will allow writing matrix multiplication in a "much more natural fashion than calling a function".

Perhaps his favorite 3.5 feature should be type hints, since it is a PEP he worked on himself. It took a lot of work for the PEP to get accepted, which is a little bizarre since he is the benevolent dictator for life (BDFL) and could accept his own PEP. But he wanted to have independent review and acceptance of the PEP, which Mark Shannon was graciously willing to provide as the BDFL delegate, he said.

If you caught him unaware, though, he probably would name the new async and await keywords for coroutines as his favorite. It was the last PEP accepted for 3.5 and it provides a more natural way of specifying coroutines.

Open bugs

Someone recently asked him about all of the open bugs in the Python bug tracker. If you pick a random open bug, you will find that it probably has patches attached to it, a bunch of discussion, and even renowned core developers saying that the patches need to go in, but the bug is still not fixed. Is it because of an old boys' network or lame core developers? What needs to be done to get those patches applied?

The situation is the same for any large project, he said. Bugs that can't be closed right away, due to things like misread documentation, tend to pile up. They can be hard to reproduce due to the hardware or environment, for example. But those kinds of bugs don't have patches attached.

There are also bugs that are feature proposals that do have patches attached, but there is a general hesitation to accept changes like that because there is concern that they aren't useful, won't mesh with other similar language features, or that they will cause backward incompatibilities. It is hard to take patches without breaking things all the time.

In addition, the core developers all have a lot on their plates and no one is paid to merge patches for core Python. So if none of the core team cares about a particular patch or feature, they may not find the time to shepherd it through the merging process.

In a company, things are a little different. People are paid to do some amount of grunge work, but with open source you have to volunteer to do unpleasant tasks. Some core developers have been doing that for so long that they want a break from that kind of grunge work. These are some of the many reasons that there are lots of open bugs with long histories in the bug tracker.

Lastly, there is a statistical effect that many overlook. If you pick any bug at random, including closed bugs, you would likely get a closed bug. Many bugs are closed quickly and bugs that are easy to fix tend to get fixed quickly. But the average lifetime of an open bug grows linearly with the age of the project, he said.

The GIL

Someone from the audience asked about the global interpreter lock (GIL), looking for more insight into the problem and how it is being addressed. Van Rossum asked back with a grin: "How much time have you got?" He gave a brief history of how the GIL came about. Well after Python was born, computers started getting more cores. When threads are running on separate cores, there are race conditions when two or more try to update the same object, especially with respect to the reference counts that are used in Python for garbage collection.

One possible solution would be for each object to have its own lock that would protect its data from multiple access. It turns out, though, that even when there is no contention for the locks, doing all of the locking and unlocking is expensive. Some experiments showed a 2x performance decrease for single-threaded programs that didn't need the locking at all. That means there are only benefits when three or more threads and cores are being used.

So, the GIL was born (though that name came about long after it was added to the interpreter). It is a single lock that effectively locks all objects at once, so that all object accesses are serialized. The problem is that now, 10 or 15 years later, there are multicore processors everywhere and people would like to take advantage of them without having to do multiprocessing (i.e. separate communicating processes rather than threads).

If you were to design a new language today, he said, you would make it without mutable (changeable) objects, or with limited mutability. From the audience, though, came: "That would not be Python." Van Rossum agreed: "You took the words out of my mouth." There are various ongoing efforts to get around the GIL, including the PyPy software transactional memory (STM) work and PyParallel. Other developers are also "banging their head against that wall until it breaks". If anyone has ideas on how to remove the GIL but still keep the language as Python, he (and others) would love to hear about it.

PyPy

He was asked about PyPy, whether he used it and whether it might someday become the default interpreter. He does not use PyPy, but he does download it once in a while, plays with it for a few minutes, and likes what he sees. He uses Python in two modes, either writing a short little script to get something done, for which he just uses one of the interpreters he already has built on his system, or as a Dropbox engineer deploying Python code to its cluster.

The Dropbox cluster runs a modified Python 2.7, he said, which elicited audience laughter. "I said it, it is no secret", he said. Some parts of Dropbox do use PyPy where it is faster, but the company is worried that some subtle incompatibility will produce weird bugs that are hard to track down. "We have enough of those already".

PyPy shows that you can execute Python faster than CPython. It also provides a testbed where interesting ideas like STM can be tried. But conservative principles lead people to only use PyPy when they know they need the speed. The problem is that by the time you find that out, you have already deployed to enough machines that it makes switching hard. In that, it is like the problem with switching to Python 3.

Dropbox has a lot of third-party dependencies, some of which cannot even be rebuilt from the sources that it has. That is generally true of any company that has millions of lines of Python in production; he also saw it at Google. That also makes switching hard.

In summary, PyPy is a "really cool project", but there are checkboxes that it needs to satisfy that "are hard to check off". He half-jokingly suggested that perhaps PyPy needed to hire Ola and Ola from Django Girls to help create a bigger community around the project.

Favorites

[Guido van Rossum]

Five short questions about his favorites was up next. Favorite web framework? He said he only writes one web app in any framework and that the last he tried was Flask. Favorite testing library? He mostly just uses unittest and mock from the standard library. Editor? He uses Emacs, but started out with vi (both of which were greeted with applause, presumably by different sets of audience members). He still uses vi (or Vim) occasionally, but if he does that for five minutes, it takes him fifteen minutes to get used to Emacs again.

What is his favorite language besides Python? He used to say C, but "that's kind of boring". People he trusts tell him that modern C++ is a good language. He likes Go, but hasn't written anything significant in it. From talking with the designers, he likes the looks of Swift, which stole a bunch of things from Python. It is easy to steal bad stuff from languages you like and end up with an incoherent pile of features, but Swift's designers appear not to have done that. Finally, favorite exception? He chuckled and answered KeyboardInterrupt to more applause and laughter.

And what he hates

The final question was about what he hates in Python. "Anything to do with package distribution", he answered immediately. There are problems with version skew and dependencies that just make for an "endless mess". He dreads it when a colleague comes to him with a "simple Python question". Half the time it is some kind of import path problem and there is no easy solution to offer.

With that, his time was up. The EuroPython organizers had a gift for each of the keynote speakers: a Basque beret and bandana. They were presented to Van Rossum at the end of the talk (seen above at right).

Index entries for this article
ConferenceEuroPython/2015


(Log in to post comments)

Guido on Python

Posted Jul 23, 2015 17:35 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link]

Huh. Even Guido's own employer has no plans to migrate to Python 3, the greatest advantage of Python 3 is "ease of teaching" (whatever it is) and Python 2.7 is being maintained indefinitely.

Am I the only one who thinks that doing the same thing over and over again (releasing new Python 3 versions without releasing a credible upgrade path) and expecting a different result is close to the dictionary definition of madness?

Guido on Python

Posted Jul 23, 2015 19:11 UTC (Thu) by SEMW (guest, #52697) [Link]

> Guido's own employer has no plans to migrate to Python 3

Do you have a source for that? (The article only says that it currently runs 2.7, which is rather different from having no plans to migrate).

Guido on Python

Posted Jul 27, 2015 7:29 UTC (Mon) by jmcs (guest, #103721) [Link]

Python 2.7 already as an end of life set (2020). What do you call "a credible upgrade path"? If you are using python 2.7 it's easy to make code compatible with python 3.3+ you just need to put some time into it.

Guido on Python

Posted Jul 27, 2015 13:05 UTC (Mon) by mathstuf (subscriber, #69389) [Link]

You are assuming all Python2.7 code resides in .py files and not .c or .cxx files. And doesn't need to support 2.7 and 3.x at the same time (or, heaven forbid, all the way back to 2.4 as well). While I've done 2.4 through 3.3 support in a single codebase, you lose things like `with`, catching exceptions into variables (luckily `sys.exc_info` exists), decorators (which can be supported with direct function calls and assignment instead), and other fun bits because of *syntax* problems.

I agree that it's less painful the earlier you start, but 2019 will probably have lots of "save us from our own poor planning!" consulting jobs popping up. Also probably 2021.

Guido on Python

Posted Jul 27, 2015 17:29 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]

> Python 2.7 already as an end of life set (2020).
Not going to happen. There's too much 2.7 code to be _rewritten_ by that time.

> What do you call "a credible upgrade path"?
A Python version (call it 3.8 or whatever) that can run both Python 3 and Python 2.7 code.

> If you are using python 2.7 it's easy to make code compatible with python 3.3+ you just need to put some time into it.
No, it's not easy. We tried that, and eventually abandoned - some of the stuff (like metaclasses) is hard to keep compatible.

And then there's a question of why we should do it - Python3 brings nothing interesting, except Unicode braindeadness. Yet it requires non-trivial rewrites of perfectly working Python2.7 code. If Python3 adds real multithreading with lightweight tasks, perhaps it will be a good motivation to start a serious migration initiative.

Personally, right now I'm pushing for migration to Go instead - its designers are mostly sane.

Guido on Python

Posted Jul 31, 2015 12:16 UTC (Fri) by agentultra (guest, #103830) [Link]

If you're having trouble with compatibility there are large, non-trivial projects such as Openstack Cinder, Swift, and others who have ported their code to support 2.7/3.x by using compatibility libraries such as 'six'. Meta-classes are a simple class decorator and boom, you'd done.

Guido on Python

Posted Jul 31, 2015 20:00 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

Nope. I don't know about Swift, but OpenStack porting required a lot of effort to update all the dependencies. And it's _still_ not 100% complete.

For non-trivial codebases it's never "just run 2to3".

Guido on Python

Posted Jul 31, 2015 14:45 UTC (Fri) by jafo (guest, #8892) [Link]

So let me get this straight: You don't have time to port Python 2.7 to 3.x, but you do have time to completely re-tool and educate engineers in Go and re-write from the ground up? Interesting.

Guido on Python

Posted Jul 31, 2015 19:57 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

> So let me get this straight: You don't have time to port Python 2.7 to 3.x, but you do have time to completely re-tool and educate engineers in Go and re-write from the ground up? Interesting.
We don't want to _rewrite_ everything in Python 3 (and yes, it has to be a rewrite). So we use and evolve our Python 2.7 code (and will keep doing it past 2020 for sure), but at the same time new incremental projects are now done in Go or Java.

The main impediment is not learning the language (software engineers are not idiots and can read TFMs), but maintaining two codebases and making sure that the switch from v2 to v3 is transparent for the users.

Guido on Python

Posted Jul 31, 2015 6:47 UTC (Fri) by j3persson (guest, #103820) [Link]

While it may not benefit you, "releasing new Python 3 versions without releasing a credible upgrade path" benefits existing and future Python 3 projects, which increase in number daily. Either Python 3 will eventually be worth the effort to upgrade, or it won't. In the latter case, maybe Python 2.7 is simply good enough for the existing project? There's nothing wrong with that.

Guido on Python

Posted Jul 31, 2015 9:33 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

No, it doesn't benefit Python projects. For example, PyPy is still written in Python 2.7 because a rewrite is too costly and pointless. This slowly leads to accumulation of technical debt, which will bite Python someday.

Me? I'm sick of Python and I am moving my team over to Go and Java.

Guido on Python - The way forward

Posted Jul 31, 2015 14:28 UTC (Fri) by brianmhunt (guest, #103835) [Link]

I feel the Python project should have a view to a version 4 of Python that:

1. Fixes the issues with unicode/text/bytes;
2. Is almost entirely transparent compatibility with Python 2.x;
3. Has optional compile-time or runtime benefits of Python 3.x, where it makes sense; and
4. Adds the library updates of Python 3.x.

In other words, treat Python 3 as an experiment and abandon the bits that are unpalatable to Python 2.x users. Kill your darlings, as they say.

It feels like something along these lines is what has to happen for Python to have a bright future beyond 2.x i.e. one that isn't joining Perl 6 et al.

Guido on Python - The way forward

Posted Jul 31, 2015 14:54 UTC (Fri) by mathstuf (subscriber, #69389) [Link]

> Adds the library updates of Python 3.x.

I'd rather they *split* the standard library rather than try stuffing more things into it. Some of those things really need to not be tied to the Python release schedule (security-related ones come to mind first, but basically any that have external "better" versions too).


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds