So for legacy reasons I have to deal with a data store that has the format
obj.dict1 = {keyA:{key1:(3xN np array),
key2:(3xN np array),
key3:(3xN np array)}
keyB:{key1:(3xN np array),
key2:(3xN np array),
key3:(3xN np array)}
}
and I am trying to get two different lists quickly:
[ obj.dict1[keyA][key1](0,:), obj.dict1[keyA][key2](0,:), obj.dict1[keyA][key3](0,:) ][ obj.dict1[keyA][key1](0,:), obj.dict1[keyB][key1](0,:) ]
So far for both of these I am building a for loop that goes over either the inner or out keys. It works alright but was hoping for something more pythonic with list comprehension
EDIT
The loop for 1. is
keyList = ['key1','key2','key3']
tmpArray = np.zeros((3,N))
for ii in range(3):
tmpArray[ii,:] = obj.dict1['keyA'][keyList[ii]][0,:]
If it can't be faster or simpler that's fine but this is then inside another for loop that gets repeated quite a few (>50) times.