Database in memory

Nicko usenet at nicko.org
Tue Apr 10 19:32:54 CEST 2007


On Apr 10, 1:10 pm, "Nicko" <use... at nicko.org> wrote:
> If you expect to do exact-match look-up where the keys are not unique
> then build a dictionary containing 'set' objects which are the sets of
> records which have the given key. This lets you neatly find the
> intersection of selections on multiple criteria (e.g. matches =
> zipcode_index["94101"] & hometype_index["condo"] ).

Just FYI, if you're going to go this route then the items that you are
indexing have to be hashable, which the built in 'list' type is not.
Tuples are, or you can make some custom class (or your own subtype of
list) which implements the __hash__ method based on some 'primary key'
value from your data.  Or you could just go for SQLite...




More information about the Python-list mailing list