13. Data Persistence

#
13. Data Persistence

The modules described in this chapter support storing Python data in a persistent form on disk. The `pickle` and `marshal` modules can turn many Python data types into a stream of bytes and then recreate the objects from the bytes. The various DBM-related modules support a family of hash-based file formats that store a mapping of strings to other strings. The `bsddb` module also provides such disk-based string-to-string mappings based on hashing, and also supports B-Tree and record-based formats.

The list of modules described in this chapter is:

`pickle` |  | Convert Python objects to streams of bytes and back.
`cPickle` |  | Faster version of `pickle`, but not subclassable.
`copy_reg` |  | Register `pickle` support functions.
`shelve` |  | Python object persistence.
`marshal` |  | Convert Python objects to streams of bytes and back (with different constraints).
`anydbm` |  | Generic interface to DBM-style database modules.
`whichdb` |  | Guess which DBM-style module created a given database.
`dbm` |  | The standard ``database'' interface, based on ndbm.
`gdbm` |  | GNU's reinterpretation of dbm.
`dbhash` |  | DBM-style interface to the BSD database library.
`bsddb` |  | Interface to Berkeley DB database library
`dumbdbm` |  | Portable implementation of the simple DBM interface.
`sqlite3` |  | A DB-API 2.0 implementation using SQLite 3.x.