Wednesday, June 21, 2006

Python development history by the numbers

Here are some more statistics and milestones in the history of Python development. One of the key events in the development was the migration of Python's CVS repository to SourceForge, which Guido announced on May 21, 2000. It represented the first time that people other than Guido's direct co-workers had direct access to the CVS repository.

At about the same time that Python started using SourceForge, Greg Wilson alerted us to the recently started Subversion project at tigris.org. We eventually started using Subversion five years later. Martin v. Loewis announced the migration on Oct. 19, 2005.

Given those couple of simple milestones, I wondered how many people had commit privileges for Python CVS over time. The Python Subversion/CVS history starts on Aug 9, 1990 and Guido remains the only committer until 1992 when Jack Jansen and Sjoerd Mullender start making changes. A small number of people got additional privileges over the years.
  • 1994: Barry Warsaw
  • 1995: Fred Drake and Roger Masse
  • 1997: Jeremy Hylton
  • 1998: Andrew Kuchling, Ken Manheimer, Greg Ward
  • 1999: Greg Stein, Just van Rossum
This list doesn't capture the people who were making contributions by sending patches. Tim Peters was making contributions from the early days. Many of my earlier checkins were adding code written by other people, including Andrew Kuchling's zlib improvements, Greg Ewing's extended call syntax patch, and Neil Schemenauer's garbage collection patches.

The migration to SourceForge allowed many more people to have access. There were nine committers in 1999 and 35 in 2000. The number grew to about 49 in 2004. This year 36 different people have made checkins.

We can also count the total number of checkins by year, which reflects the same kind of explosion of activity in 2000 when 26 new developers started committing code. The PythonLabs team (Barry, Fred, Guido, Tim, and I) were working full-time on Python for a good part of 2000, so that also contributed to the surge in developer activity.

The raw number of checkins per year was:
  • 1990: 105 checkins
  • 1991: 445 checkins
  • 1992: 627 checkins
  • 1993: 287 checkins
  • 1994: 578 checkins
  • 1995: 1249 checkins
  • 1996: 1544 checkins
  • 1997: 2159 checkins
  • 1998: 2718 checkins
  • 1999: 1897 checkins
  • 2000: 4035 checkins
  • 2001: 5508 checkins
  • 2002: 4238 checkins
  • 2003: 3563 checkins
  • 2004: 2529 checkins
  • 2005: 1273 checkins
  • 2006: 1599 checkins

Wednesday, June 14, 2006

Using indentation to represent program structure

I've heard Guido mention that Donald Knuth made an early suggestion that future programming languages would use indentation as a structuring mechanism. I decided to dig into that history a little bit today. Knuth quotes D. V. Schorre who writes
Since the summer of 1960, I have been writing programs in outline form, using conventions of indentation to indicate the flow of control.
Knuth quoted this in the context of his long paper "Structured Program with go to Statements" (p. 295) where he wrote:
It seems clear that languages somewhat different from those in existence today would enhance the preparation of structured programs. We will perhaps eventually be writing only small modules which are identified by name as they are used to build larger ones, so that devices like indentation, rather than delimiters, might become feasible for expressing local structure in the source language.
Knuth also mentions Peter Landin's ISWIM family of languages. In "The Next 700 Programming Languages," Landin discusses four levels of abstraction in programming languages--physical, logical, abstract, and applicative expressions. The physical and logical languages involve syntactic issues like grammatical rules for grouping textual elements. Landin also mentions that ALGOL "sought to avoid any commitment to any particular sets of characters or type faces."

Landin's preferred representation for ISWIM used indentation. The paper has a section that lists differences between ISWIM and LISP, including the "textual appearance of ISWIM."
(c) Indentation, used to indicate program structure. A physical ISWIM can be defined in terms of an unspecified parameter: a subset of phrase categories, instances of which are restricted in layout by the following rule called "the offside rule." The southeast quadrant that just contains the phrase's first symbol must contain the entire expression, except possibly for bracketed subsegments.... It is based on vertical alignment, not character width, and hence is equally appropriate in handwritten, typset or typed texts.
In the next sentence, he observes that indentation is not mandatory. It can be freely mixed with more conventional punctuation.

The discussion, presumably from the conference, starts with a discussion of indentation. Peter Naur raises an immediate objection, oen that is raised today about Python programs.
Regarding indentation, in many ways I am in sympathy with this, but I believe that if it came about that this notation were used for very wide communcation and also publication, you would regret it because of this kind of rearrangement of manuscripts done in printing.
Robert Floyd also objected:
It works on the micro-scale--that is, one page is all right--when dealing with an extensive program, turning from one page to the next there is no obvious way of indicating how far the indentation stretches because there is no printing at all to indicate how far you have indented.
References

Donald E. Knuth
Structured Programming with go to Statements
ACM Computing Surveysm, Vol. 6, No. 6, December 1974
pp. 261-301

D.V. Schorre
Improved organization for procedural languages
Technical memo TM 3086/002/00, Systems Development Corp., Santa Monica, Ca.
Sept. 8, 1966
(I haven't seen the original. This citation is just a copy of Knuth's.)

P. J. Landin
The Next 700 Programming Languages
Communications of the ACM, Vol. 9, No. 3, March 1966
pages 157-166

The paper was presented at the ACM Programming Languages and Pragmatics Conference, Aug. 8-12, 1965 in San Dimas, Ca. The printed version of paper includes some discussion, presumably from that conference.

Wednesday, June 07, 2006

Search and Sort

Two recent posts had interesting things to say about basic searching and sorting algorithms. Josh Bloch found a bug in the JDK binary search implementation. The bug is that the code to pick the mid point can overflow if the array being searched has more than a billion or so elements, leading to a nonsense value (negative number). My first reaction was that Python doesn't have this problem. Adding two numbers does the natural thing--promotes the result from int to long.

A contemporaneous post from Jim Roskind, who wrote the Python profile module among other things, talks about a bad input to quicksort.

We were typically sorting an array of length 1000. If I remember the numbers correctly, the profiler revealed that the hot comparison function was being called over 400,000 times per sort. This was a whole lot closer to what I’d expect from an n-squared sort algorithm than from an n * log(n) quick sort. Remembering that algorithms 101 taught that quick sort *can* be an n-squared sort if the pivots are “chosen poorly,” and this could commonly happen (with a simple quick sort implementation) when the list was already mostly sorted… I took a wild guess that this was the problem. To take a shot at working around this quick sort implementation, I needed to randomize the list prior to the sort. With Python, this was a snap (to try). I just put the list into a hash table, and then pulled it out (in its pseudo random order) before doing the sort. Sure enough, a factor of 20 performance improvement resulted (for our application), and a simple bug report went off to Guido. I always liked this story because it was a case where adding wasteful code was VERY helpful.
Note to Grail users: You can visual quicksort (probably not for billion-element inputs) using my visualization applet.

Note: Jim's post about quicksort stuck in my mind, somehow, and I read Josh's post as if it were about quicksort, which doesn't make any sense. One benefit of that gaffe is that Josh referred me to Engineering a Sort Function by Bentley and McIlroy.

Friday, May 26, 2006

Rick Santorum Veterans Chair

Kevin Dellicker is going to be the veterans chair for Rick Santorum's re-election campaign.

Thursday, May 25, 2006

Contributing to Python

I did not get involved in Python development until I'd been at CNRI for a couple of years. If I look at the Python history file and CVS/SVN logs, I did make a single checkin until 1997. My first projects were the resource module and improvements to the zlib/gzip interface.

The resource module exposes the Unix getrusage/setrusage system calls. I created it when we were working on the Knowbot system, because we wanted to be able to limit the resource consumption of hosted programs (Knowbots). I don't recall that we ever made much progress on the resource consumption problem, though. Anyway, this was my first contribution to Python, but I see that I gave it to Guido and he checked it in for me after some editing. I was a fairly novice C programmer at the time.

The other project I worked on at that time was improvements to the zlib interface. These represent my first actual checkins--in the summer and fall of 1997. I can't recall how much of the working was original. Andrew Kuchling had done a lot of work in this area and wrote the original gzip module. Since no one outside CNRI had CVS access, I was checking in Andrew's code. But I think I made some original contributions here, too.

I'll see if I can think of more stories from early development projects. For now, I'll just summarize the raw data from the CVS/SVN log. I have made 931 checkins to the Python project. By year, the breakdown is
  • 1997, 10 checkins
  • 1998, 15 checkins
  • 1999, 11 checkins
  • 2000, 212 checkins
  • 2001, 376 checkins
  • 2002, 157 checkins
  • 2003, 117 checkins
  • 2004, 18 checkins
  • 2005, 8 checkins
  • 2006, 18 checkins
It's no surprise that 2000 and 2001 were my most active years. PythonLabs joined BeOpen in 2000 and we spent a few months working almost full-time on Python development. I was release manager for Python 1.6 and Python 2.0, which was a whole lot of fun. The numbers are probably a little inflated from that time, because we didn't have open CVS access in early 2000.

Wednesday, May 24, 2006

My First Python Projects

I joined CNRI in February 1996. I worked with a great group of people: Fred Drake, Ken Manheimer, Roger Masse, Guido van Rossum, and Barry Warsaw. Our first manager was Ted Strollo. I think Fred started just a few weeks before I did, but he knew a lot more about Python and didn't seem like he was new.

The team was working on Grail, a web browser written in Python with Tkinter, and on Knowbots, which allowed you to write Python programs that could ship themselves around to different servers. We spent more time on Grail at first, but I think Guido had written an initial demo to support mobile Python programs before I joined.

One of my first programming tasks was the client-side HTTP cache for Grail. I don't recall what I else I did for Grail. Many years later, I wrote urllib2 to have a more flexible tool for writing HTTP client programs, probably based on some of my early HTTP experiences with Grail. I recall one funny story about the cache: We were having problems with the cache because reading the cache on startup was too expensive. It stored one page to a file and kept a log with all the metadata updates. I had simple code that read and parsed one line at a time to generate a list of tuples with the metadata. I think I tried five or six different ways to make it faster but it was still too slow. I finally struck upon using pickles instead of parsing the data by hand and then I tried cPickle. It was 8,000 times faster than the original log parsing code!

Grail was a really fun project, but surely sounds odd ten years later. Why would anyone want to write a browser in Python? At the time, web browsers weren't mature software and it was useful to have a relatively complete browser for which you had the full source in a high-level language. We did support applets written in Python. I wrote a quicksort visualization applet. Looking at the docstring, it says it was my second real Python program.

Another Python memories post.

How I Learned Python

Guido is working on a paper for the HOPL III conference. He recently asked old timers to post their memories. I thought I'd start at the beginning.

I learned Python on a plane ride from Boston to Baltimore in the fall of 1995. I was interviewing for a job at CNRI. I expected to talk mostly about digital libraries, because my thesis was in that area and I thought I was interviewing with people in the digital libraries group. But I also knew that I was going to meet Guido, and I thought I better know something about Python. I printed out the tutorial and brought it with me on the plane.

I didn't know anything about Python at the time. I knew Perl relatively well, had used Tcl a couple of times, and had heard of Python. I recall one corridor conversation, with John Mallery I think, where he gave me a hard time about using scripting languages like Perl. I said something along the lines of "Well what about Python" and he granted that it was a more reasonable choice.

I got a first-class ticket for the flight. I think we scheduled the interview at the last minute and they were the only tickets available. It was a comfortable, short ride. I spent most of it reading the Python tutorial. I recall thinking that the language was really simple--that you could get the gist of it from the tutorial without writing a line of code. And sample was good! I had struggled a lot with Perl, because I felt like I had never mastered it and I had to look everything up in the Camel book. I could never settle on the right way to solve a particular problem, because there were so many options.

The interview itself must have gone well, although I don't recall many of the details. The only concrete memories I have are talking with Bob Kahn and Ken Manheimer. I don't have any recollection of talking with Guido at the interview, although I'm sure I did.