Object Persistence Modules
Three modules comprise the object persistence interface.
anydbmin Python 2.X)
Key-based string-only storage files.
cPicklein Python 2.X)
Serializes an in-memory object to/from file streams.
Key-based persistent object stores: pickles objects to/from
shelve module implements
persistent object stores.
turn uses the
pickle module to
convert (serialize) in-memory Python objects to byte-stream strings and
dbm module to store serialized
byte-stream strings in access-by-key files.
In Python 2.X,
dbm is named
anydbm, and the
cPickle module is an optimized version of
pickle that may be imported
directly and is used automatically by
shelve, if present. In Python 3.0,
cPickle is renamed
_pickle and is automatically used by
pickle if present—it need not be
imported directly and is acquired by
Also note that in Python 3.0 the Berkeley DB (a.k.a.
bsddb) interface for
dbm is no longer shipped with Python itself,
but is a third-party open source extension which must be installed
separately (see the Python 3.0 Library Reference for
dbm and shelve Modules
dbm is an access-by-key filesystem: strings are stored and fetched by their string keys. The
dbm module selects the keyed-access
file implementation in your Python interpreter and presents a
dictionary-like API for scripts. A persistent object
shelve is used like a simple dbm file, except that the
dbm module is replaced by
shelve, and the stored