PyDocs

Nav

Data Persistence

Shelf

shelve

class (source)
  • Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8', *, serializer=None, deserializer=None)
Base class for shelf implementations.

This is initialized with a dictionary-like object.
See the module's __doc__ string for an overview of the interface.
Changed in 3.2, 3.4, 3.10, 3.15
  • 3.2: Added the keyencoding parameter; previously, keys were always encoded in UTF-8.
  • 3.4: Added context manager support.
  • 3.10: pickle.DEFAULT_PROTOCOL is now used as the default pickle protocol.
  • 3.15: Added the serializer and deserializer parameters.
Members of Shelf

c

close
Synchronize and close the persistent dict object.

r

reorganize
Calls sync() and attempts to shrink space used on disk by removing empty space resulting from deletions.

s

sync
Write back all entries in the cache if the shelf was opened with writeback set to True.
0 Examples
No examples for shelve/Shelf.
See Also
No see-alsos for shelve/Shelf
0 Notes
No notes for Shelf