Do you really need to load or reset all this in memory at once? If you do not need all this in memory, but only the selected parts that you want at any given time, you may need to map your dictionary to a set of files on disk instead of a single file ... or map a dict to a database table. So, if you are looking for something that saves large dictionaries of data on disk or in a database and can use etching and encoding (codecs and hash cards), you can look at klepto .
klepto provides a dictionary abstraction for writing to a database, including treating your file system as a database (i.e. writing the entire dictionary to a single file or writing each record to its own file). For big data, I often prefer to present the dictionary as a directory in my file system, and each one should be a file. klepto also offers caching algorithms, so if you use a file system file system for a dictionary, you can avoid some speed reduction by using memory caching.
>>> from klepto.archives import dir_archive >>> d = {'a':1, 'b':2, 'c':map, 'd':None} >>>
klepto also has other flags, such as compression and memmode , which can be used to configure how your data is stored (e.g. compression level, memory card mode, etc.). It is equally simple (the same exact interface) to use a database (MySQL, etc.) as a backend instead of your file system. You can also disable memory caching, so each read / write goes directly to the archive, just setting cached=False .
klepto also provides many caching algorithms (e.g. mru , lru , lfu , etc.) to help you manage the cache in memory and will use the algorithm to dump and upload to the archive server for you.
You can use the cached=False flag to completely disable memory caching, as well as directly read and write to disk or from the database and vice versa. If your records are large enough, you can select a record to disk, where you put each record in its own file. Here is an example that does both.
>>> from klepto.archives import dir_archive >>>
However, while this should significantly reduce boot time, it can slow down overall execution down a bit ... it's usually best to specify the maximum amount to be stored in the memory cache and choose a good caching algorithm. You must play with him to get the right balance for your needs.
Get klepto here: https://github.com/uqfoundation