need optimizing help

William Park opengeometry at yahoo.ca
Sat Mar 13 15:22:20 EST 2004


rabbits77 <rabbits77 at bigmailbox.net> wrote:
> I have a dictionary with a very very large(possibly millions) of
> key/value pairs.
> The key is a tuple that looks like (id,date)
> What is the fastest way to get out all of the values that match any
> key given that they individual key elements are coming from two
> seperate lists?
> The approach of
> for id in IDS:
>     for date in dates:
>         data=myDict[(id,date)]
> 
> seems to just take too long. Is there a speedier, more pythonic, way
> of doing this? Any help speeding this up would be much appreciated!!

Hmm... since you're looking up every possible combination of 'id' and
'date', there is no short cut of algorithm.  As for speed, it may be
faster to use external database.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data processing and document management.



More information about the Python-list mailing list