Saturday, April 11, 2009

The best PyCon talk you didn't see

There were a lot of good talks at PyCon but I humbly submit that the best one you haven't seen yet is Robert Brewer's talk on DejaVu. Robert describes how his Geniusql layer disassembles and parses python bytecode to let his ORM turn python lambdas into SQL. Microsoft got a lot of press for doing something similar for .NET with LINQ, but Bob was there first.
  box = store.new_sandbox()
print [c.Title for c in box.recall(
  Comic, lambda c: 'Hob' in c.Title or c.Views > 0)]
This is cool as hell. The Geniusql part start about 15 minutes in.

4 comments:

Bob Ippolito said...

Erlang has had this for a very long time too, at least for Mnesia databases, e.g. Mnemosyne and later QLC. Cool stuff :)

j_baker said...

Hah! I proved you wrong. I did see that talk. Shows you.

Seriously though, I've been meaning to try dejavu out for a while and this gives me new impetus to give it a shot.

Rob De Almeida said...

I did something similar: a DB API wrapper that parses the source code to build the SQL:

http://pypi.python.org/pypi/simpleQL

The only problem is that it doesn't work on an interactive session, since it needs to read the source code.

Catherine said...

I liked it a lot, too. I haven't yet had time to figure out if I want to use DejaVu in general, but the principle is a great one: why make people learn a new syntax for something (like filtering rows) when they already know a perfectly good syntax for it?