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.


André said...

Out of curiosity, I downloaded grail and try to run it. Unfortunately, it failed (with Python 2.4). Do you have any idea if someone else tried to make it compatible with later version of Python?

Jeremy Hylton said...

I think it's been years and years since there was a Python version that ran Grail. It's not much of a web browser by modern standards--no frames, no CSS, no Javascript.

André said...

... no frames, no CSS, no Javascript. Perhaps, but there were Python applets! It's really too bad that modern browser do not allow some subset of Python (not Jython) to be used to create applets...

Guido van Rossum said...

"Why would anyone want to write a browser in Python?"

Isn't a large part of FireFox written in JavaScript? That would validate the idea, wouldn't it? After all Grail's rendering engine relied on Tk, just like FF relies on XUL.

Pete said...

Umm, why wouldn't you want to write a webbrowser in Python?


Barry Warsaw said...

Great post Jeremy -- brings back lots of memories! IIRC, the original prototype of Grail was written in something like two weeks and mostly as a skunkworks project. After the raw prototype was running, REK came to us and asked (paraphrasing): wouldn't it be cool if we had a browser written in Python that could execute Python applets? Our response was, yeah, do you want to see it? I think it was the first concrete evidence of the infamous time machine I ever witnessed. :)

Oh, and Grail did have frames, but they sucked. Hard. I remember implementing them using Tk wizardry but Tk was just not up to the task and the implementation was horribly slow.

Anonymous said...


I would like to use a webbrowser written in python. A question that i can read many time is what for?

My first reason is that for security reasons and because i dont understand enought, i prefer to read sources. A well written python program is my best chance to understand.

Second reason is to maintain open sources vitality, and keep open open standards, same reason will apply.

Next step will be a OS written in python of course.