I'm keeping a record of what I'm calling profile
s.
Each profile
is a tuple of dictionaries: (Dict,Dict)
, and we can associate to it a unique id
(may include characters like _
or -
).
I need to keep them in RAM memory for a certain time, because I'll need to search and updated some of them, and only at the end, when I no longer need the whole set of profile
s will I flush them to persistent storage.
Currently, I'm using a dictionary/hash table to keep all of them (number of elements around 100K, but could be more), since I'll do many searches, using the id:profile
as the key:value
pair.
The data looks similar to this:
{
"Aw23_1adGF":({
"data":
{"contacts":[11,22],"address":"usa"},
"meta_data":
{"created_by":"John"}
},{"key_3":"yes"}),
"AK23_1adGF":({
"data":
{"contacts":[33,44],"address":"mexico"},
"meta_data":
{"created_by":"Juan"}
},{"key_3":"no"}),
# ...
}
Once this data structure is built, I don't need to add/delete any more elements. I only build it once, than search it many times. On certain occasions I'll need to update some element in the dictionaries that compose a profile. However, building this data object contributes to the peak RAM usage that I'm trying to diminish.
The problem is that the dictionary seems to use too much RAM.
What were my other options regarding data structures that could keep some of the search efficiency and with a small RAM footprint?
I thought of an ordered list, since the id
seems to me to be orderable (maybe except for characters like _
or -
).
What data structures are there that could help me in this predicament?