Hashed lookups for tabular data

Joseph L. Casale jcasale at activenetwerx.com
Mon Jan 19 09:13:29 EST 2015


I have some tabular data for example 3 tuples that I need to build a container
for where lookups into any one of the three fields are O(1). Does something
in the base library exist, or if not is there an efficient implementation of such
a container that has been implemented before I give it a go?

It complicates slightly by the fact that for the some of the collections, one of
the fields may be duplicated, think (make, model, year) for example which
closely resembles the pattern of one the data sets. When asking for position
0 of the set, I'd expect to get an iterable of length "n" but some of the containers
will be inherently unique for the rows that will be accessed so I'd return a single
row.

No surprise the data originates from a database however the data is utilized in
a recursive processing loop where the user accessing the data benefits from a
simplified and quick means to access it. Currently its done with classes that
resemble named tuples equating to a row, but it goes pear shaped with the outer
container. Grouping these similar objects and providing the sql like query into
the collection in some cases is O(n)...

Thanks,
jlc



More information about the Python-list mailing list