pickle.dump(object,file,protocol) #To serialize an object
pickle.load(file) #To de-serialize an object
pickle.dumps(object, protocol) # To serialize an object to bytes
pickle.loads(buffer) # To de-serialzie an object from bytes
| Parameter | Details |
|---|---|
| object | The object which is to be stored |
| file | The open file which will contain the object |
| protocol | The protocol used for pickling the object (optional parameter) |
| buffer | A bytes object that contains a serialized object |
The following objects are picklable.
None, True, and Falsetuples, lists, sets, and dicts containing only picklable objects__dict__ or the result of calling __getstate__() is picklable (see the official docs for details).Based on the official Python documentation.
pickle and securityThe pickle module is not secure. It should not be used when receiving the serialized data from an untrusted party, such as over the Internet.