shelve.Shelf

class shelve.Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8')

A subclass of collections.abc.MutableMapping which stores pickled values in the dict object.

By default, version 3 pickles are used to serialize values. The version of the pickle protocol can be specified with the protocol parameter. See the pickle documentation for a discussion of the pickle protocols.

If the writeback parameter is True, the object will hold a cache of all entries accessed and write them back to the dict at sync and close times. This allows natural operations on mutable entries, but can consume much more memory and make sync and close take a long time.

The keyencoding parameter is the encoding used to encode keys before they are used with the underlying dict.

A Shelf object can also be used as a context manager, in which case it will be automatically closed when the with block ends.

Changed in version 3.2: Added the keyencoding parameter; previously, keys were always encoded in UTF-8.

Changed in version 3.4: Added context manager support.

doc_python
2016-10-07 17:41:50
Comments
Leave a Comment

Please login to continue.