suefile open('sue pkl''wb'pickle dump(suesuefilesuefile close(here are our file-per-record scripts in actionthe results are about the same as in the prior sectionbut database keys become real filenames now in sensethe filesystem becomes our top-level dictionary--filenames provide direct access to each record \pp \previewpython make_db_pickle_recs py \pp \previewpython dump_db_pickle_recs py bob pkl ={'pay' 'job''dev''age' 'name''bob smith'sue pkl ={'pay' 'job''hdw''age' 'name''sue jones'tom pkl ={'pay' 'job'none'age' 'name''tom'sue jones \pp \previewpython update_db_pickle_recs py \pp \previewpython dump_db_pickle_recs py bob pkl ={'pay' 'job''dev''age' 'name''bob smith'sue pkl ={'pay' 'job''hdw''age' 'name''sue jones'tom pkl ={'pay' 'job'none'age' 'name''tom'sue jones using shelves pickling objects to filesas shown in the preceding sectionis an optimal scheme in many applications in factsome applications use pickling of python objects across network sockets as simpler alternative to network protocols such as the soap and xml-rpc web services architectures (also supported by pythonbut much heavier than picklemoreoverassuming your filesystem can handle as many files as you'll needpickling one record per file also obviates the need to load and store the entire database for each update if we really want keyed access to recordsthoughthe python standard library offers an even higher-level toolshelves shelves automatically pickle objects to and from keyed-access filesystem they behave much like dictionaries that must be openedand they persist after each program exits because they give us key-based access to stored recordsthere is no need to manually manage one flat file per record--the shelve system automatically splits up stored records and fetches and updates only those records that are accessed and changed in this wayshelves provide utility similar to per-record pickle filesbut they are usually easier to code step storing records persistently