Pickle data serialisation
suggest changeSyntax
pickle.dump(object,file,protocol): serialize an objectpickle.load(file): de-serialize an objectpickle.dumps(object, protocol): serialize an object to bytespickle.loads(buffer): de-serialize an object from bytes
Parameters
object: the object which is to be stored |file: the open file which will contain the objectprotocol: the protocol used for pickling the object (optional parameter)buffer: a bytes object that contains a serialized object|
Pickleable types
The following objects are picklable.
None,True, andFalse- numbers (of all types)
- strings (of all types)
tuples,lists,sets, anddicts containing only picklable objects- functions defined at the top level of a module
- built-in functions
- classes that are defined at the top level of a module
- instances of such classes whose
__dict__or the result of calling__getstate__()is picklable (see the official docs for details).
Based on the official Python documentation.
Pickle and security
The pickle module is not secure. It should not be used when receiving the serialized data from an untrusted party, such as over the Internet.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents