Tin mới
copyreg — Register pickle support functions
Relationship to other Python modules¶
The pickle module is not secure. Only unpickle data you trust.
hmac: Keyed-Hashing for Message Authentication (HMAC) implementation
The pickle module is not secure. Only unpickle data you trust.
json: Encode and decode the JSON format.
The pickle module is not secure. Only unpickle data you trust.
marshal: Convert Python objects to streams of bytes and back (with different constraints).
Python has a more primitive serialization module called marshal, but in general pickle should always be the preferred way to serialize Python objects. marshal exists primarily to support Python’s .pyc files.
The data format used by pickle is Python-specific. This has the advantage that there are no restrictions imposed by external standards such as JSON (which can’t represent pointer sharing); however it means that non-Pytho
The data format used by pickle is Python-specific. This has the advantage that there are no restrictions imposed by external standards such as JSON (which can’t represent pointer sharing); however it means that non-Pytho
shelve: Python object persistence.
What can be pickled and unpickled?¶
built-in constants (None, True, False, Ellipsis, and NotImplemented);
built-in constants (None, True, False, Ellipsis, and NotImplemented);
In this section, we describe the general mechanisms available to you to define, customize, and control how class instances are pickled and unpickled.
Custom Reduction for Types, Functions, and Other Objects¶
Sometimes, dispatch_table may not be flexible enough. In particular we may want to customize pickling based on another criterion than the object’s type, or we may want to customize the pickling of functions and classes.
By default, unpickling will import any class or function that it finds in the pickle data. For many applications, this behaviour is unacceptable as it permits the unpickler to import and invoke arbitrary code. Just consi
builtins: The module that provides the built-in namespace.
By default, unpickling will import any class or function that it finds in the pickle data. For many applications, this behaviour is unacceptable as it permits the unpickler to import and invoke arbitrary code. Just consi
xmlrpc.client: XML-RPC client access.
By default, unpickling will import any class or function that it finds in the pickle data. For many applications, this behaviour is unacceptable as it permits the unpickler to import and invoke arbitrary code. Just consi
copy: Shallow and deep copy operations.
Pickle interface constructor registration for extension types.