fastest way to search through this data object? (python)
Posted
by victor
on Stack Overflow
See other posts from Stack Overflow
or by victor
Published on 2010-03-16T18:30:19Z
Indexed on
2010/03/16
18:51 UTC
Read the original article
Hit count: 259
python
I have a data object that looks like this:
{
'node-16': {
'tags': ['cuda'],
'localNodes': [
{
'name': 'nC',
'consumesFrom': ['nA', 'nB'],
'classType': 'VectorAdder.VectorAdder'
},
{
'name': 'nB',
'consumesFrom': None,
'classType': 'RandomVector'
}
]
},
'node-17': {
'tags': ['boring'],
'localNodes': [
{
'name': 'nA',
'consumesFrom': None,
'classType': 'RandomVector'
}
]
}
}
Notice that node nA is a producer for nC. What's the fastest way to find out if a given localNode is a producer for another localnode in the data structure (and not within the same list)?
For example, I would like to know that nA (node-17) produces for nC (exists on node-16). But I don't need to know that nB produces for nC, since they exist in the same localNodes list.
© Stack Overflow or respective owner