The object will have to be converted to JSON and written to disk each time you want to save. You might want to investigate whether shelve
can meet your needs. You can persist a dictionary to disk using strings as keys and update specific keys as needed...
import shelve
db = shelve.open('data.db')
print db['keyname']
db['keyname'] = 'some new user data'
db.sync()
db.close()
The main advantage of shelve
is ease of use. Disadvantages include slow access with big files, lack of cross-system compatibility, and inability to trust files from third-party sources. So if users are expected to email files to each other or otherwise share content over a network, shelve
would not be a secure choice.