objects are unique only within key although the shelve module is smart enough to detect multiple occurrences of nested object and re-create only one copy when fetchedthis holds true only within given slotdbase[key[objectobjectokonly one copy stored and fetched dbase[key object dbase[key object bad?two copies of object in the shelve when key and key are fetchedthey reference independent copies of the original shared objectif that object is mutablechanges from one won' be reflected in the other this really stems from the fact the each key assignment runs an independent pickle operation--the pickler detects repeated objects but only within each pickle call this may or may not be concern in your practiceand it can be avoided with extra support logicbut an object can be duplicated if it spans keys updates must treat shelves as fetch-modify-store mappings because objects fetched from shelve don' know that they came from shelveoperations that change components of fetched object change only the in-memory copynot the data on shelvedbase[keyattr value shelve unchanged to really change an object stored on shelvefetch it into memorychange its partsand then write it back to the shelve as whole by key assignmentobject dbase[keyobject attr value dbase[keyobject fetch it modify it store back-shelve changed (unless writebackas noted earlierthe shelve open call' optional writeback argument can be used to avoid the last step hereby automatically caching objects fetched and writing them to disk when the shelve is closedbut this can require substantial memory resources and make close operations slow concurrent updates are not directly supported the shelve module does not currently support simultaneous updates simultaneous readers are okbut writers must be given exclusive access to the shelve you can trash shelve if multiple processes write to it at the same timewhich is common potential in things such as server-side scripts on the web if your shelves may be updated by multiple processesbe sure to wrap updates in calls to the os open standard library function to lock files and provide exclusive access databases and persistence