You should be able to dump an element in parts to a file. Two design issues that require subsidence:
- How do you build an object when you put it in memory?
- How do you need data when it leaves memory?
If your build process fills the entire array associated with the given key at a time, you can simply reset the key: array in the file as a separate dictionary:
big_hairy_dictionary['sample_key'] = pre_existing_array marshal.dump({'sample_key':big_hairy_dictionary['sample_key']},'central_file')
Then, when updating, each call to marshal.load ('central_file') will return a dictionary that you can use to update the central dictionary. But it really will be useful only if you need to return data, you want to process the reading of "central_file" once per key.
Alternatively, if you populate the elements of an array with elements in a specific order, try:
big_hairy_dictionary['sample_key'].append(single_element) marshal.dump(single_element,'marshaled_files/'+'sample_key')
Then, when you download it back, you donβt have to build the entire dictionary to return what you need; you simply call marshal.load ('marshaled_files / sample_key') until you return None, and you have everything associated with the key.
source share