Published 20 Mar 2012
Time for the final round of talks from PyCon 2012!
In case you missed it, in the first of this series of posts I talked about an introductory lecture on PDB, the Python debugger, a cloud hosting 101 from a noob to noobs, and a two and a half-hour demystification of some often misunderstood behavior of the Python programming language.
Van Lindberg presents a lecture on applied graph theory disguised as a Python lecture. But don’t think that’s bad at all!
The lecture consists of three studies on how graphs can model and help analyze the Python community and development process, with interesting results.
First, the python-dev mailing list is modeled using a directed graph in which there’s an edge between two people if one replied to a topic by the other. Using the concept of vertex centrality to model activity, the top three contributors to the mailing list are elicited. Interestingly, although the graph clearly shows a central core of active contributors, it contains no cliques, that is, no group of people always interact with each other.
Then, a graph is used to correlate people in the mailing list with their topics of interest. Finally, another graph tracks down the different licenses used in the Python code base.
I may be biased due to the fact that I happen to like graph theory, but I definitely enjoyed watching this. On the Python front, I learned a bit about NetworkX, an impressive package for graph manipulation and analysis.
Larry Hastings gives an “architectural sightseeing” of the internals of CPython, the reference implementation of Python, which promises to get the audience started on the path to becoming a core developer.
As the presenter himself puts it, this talk is more about “running” than “stepping” through CPython due to lack of time. It glosses over several architectural aspects of CPython, from the directory structure in the source code to the bytecode interpreter, through the custom memory allocator and internal object protocols, though never with quite enough information to make them digestible for those with no previous contact with the implementation.
Even so, I’d recommend following this lecture closely while browsing the CPython source code for those interested in what happens under the hood. Just make sure you use ctags or similar to keep up with the fast pace in this lecture.
As a curiosity, did you know CPython uses gcc’s computed goto extension where available when interpreting bytecodes?
An overview of several techinques and tools for unit testing Python code by Brian K. Jones. While aiming for an audience with intermediate familiarity with the programming language, this talk assumes little prior experience with testing techniques. Which is great — testing and validation are areas I (still) know little about.
This turned out to be a very enlightening talk in which you may learn a few general guidelines for writing testable code, such as creating wrapper classes around external resources and libraries so they can be easily mocked during testing, and also see a couple of real life applications of that knowledge.
An interesting Python-specific technique I gathered from this talk is resorting to monkey patching, that is, run-time modification of live objects and classes, which is made very easy by the language, to mock specific subsystems while testing. This, if used sparingly, turns out to be a Pythonic replacement for dependency injection.
The talk also promotes the use of some very interesting tools, such as coverage for measuring code coverage, and mock, which is even making its way into the standard library in the Python 3 series as I write this.
And that’s it for now! There are, of course, several other lectures available (check pyvideo.org for that), and I’ll probably watch a few more some time in the future. Let me know if I missed an important one!
Toggle Comments Next Previous