here in the interest of space also check out marshala module that serializes an object toobut can handle only simple object types pickle is more general than marshal and is normally preferred an additional related module_pickleis -coded optimization of pickleand is automatically used by pickle internally if availableit need not be selected or used directly the shelve module inherits this optimization automatically by proxy haven' explained shelve yetbut will now shelve files pickling allows you to store arbitrary objects on files and file-like objectsbut it' still fairly unstructured mediumit doesn' directly support easy access to members of collections of pickled objects higher-level structures can be added to picklingbut they are not inherentyou can sometimes craft your own higher-level pickle file organizations with the underlying filesystem ( you can store each pickled object in file whose name uniquely identifies the object)but such an organization is not part of pickling itself and must be manually managed you can also store arbitrarily large dictionaries in pickled file and index them by key after they are loaded back into memorybut this will load and store the entire dictionary all at once when unpickled and picklednot just the entry you are interested in shelves provide structure for collections of pickled objects that removes some of these constraints they are type of file that stores arbitrary python objects by key for later retrievaland they are standard part of the python system reallythey are not much of new topic--shelves are simply combination of the dbm files and object pickling we just metto store an in-memory object by keythe shelve module first serializes the object to string with the pickle moduleand then it stores that string in dbm file by key with the dbm module to fetch an object back by keythe shelve module first loads the object' serialized string by key from dbm file with the dbm moduleand then converts it back to the original in-memory object with the pickle module because shelve uses pickle internallyit can store any object that pickle canstringsnumberslistsdictionariescyclic objectsclass instancesand more because shelve uses dbm internallyit inherits all of that module' capabilitiesas well as its portability constraints shelve files