efficient updating of nested dictionaries

Edward C. Jones edcjones at erols.com
Sun Jan 25 22:33:41 EST 2004


omission9 wrote:
> I have a dictionary that looks like this
> MY_DICT[KEY_X][KEY_Y][KEY_Z]=FOO
> 
> I am having a problem updating this with a simple 
> MY_DICT.update(NEW_DICT) as update doesn't seem to care about getting 
> into the inner dicts.
> Getting the keys of each and iterating through and updating each one is 
> terribly slow as the number of keys gets bigger and bigger.
> What is the bst way to update my nested dicts?

Make a table whose rows are (KEY_X, KEY_Y, KEY_Z, FOO). If the table is 
large use MySQL or some other database. For small or medium sized tables 
try "http://members.tripod.com/~edcjones/MultiDict.py".



More information about the Python-list mailing list