relational database will be optimised to do these operations and so is likely to be faster still. I think there are a couple that Python works well with, but I've never looked into that -- others will no doubt be along with recommendations now I've raised the subject.
batteries-included support for sqlite[1] was added in 2.5 which would work pretty well for this application without the overhead (resource OR administrative) of something like MySQL or PostgreSQL.
-tkc [1] http://docs.python.org/library/sqlite3.html -- http://mail.python.org/mailman/listinfo/python-list