How to test if one dict is subset of another?
Hendrik van Rooyen
mail at microcorp.co.za
Tue Feb 20 01:19:38 EST 2007
"Jay Tee" <jeff.templon at gmail.com> wrote:
> Hi,
>
> I have some code that does, essentially, the following:
>
> - gather information on tens of thousands of items (in this case, jobs
> running on a
> compute cluster)
> - store the information as a list (one per job) of Job items
> (essentially wrapped
> dictionaries mapping attribute names to values)
>
> and then does some computations on the data. One of the things the
> code needs to do, very often, is troll through the list and find jobs
> of a certain class:
>
> for j in jobs:
> if (j.get('user') == 'jeff' and j.get('state')=='running') :
> do_something()
>
> This operation is ultimately the limiting factor in the performance.
> What I would like to try, if it is possible, is instead do something
> like this:
>
When you are gathering the data and building the lists - why do you not
simultaneously build a dict of running jobs keyed by the Jeffs?
- Hendrik
More information about the Python-list
mailing list