Pickler(file,
protocol=0)
|
|
Create a pickler.
This takes a file-like object for writing a pickle data stream. The
optional proto argument tells the pickler to use the given protocol;
supported protocols are 0, 1, 2. The default protocol is 0, to be
backwards compatible. (Protocol 0 is the only protocol that can be
written to a file opened in text mode and read back successfully. When
using a protocol higher than 0, make sure the file is opened in binary
mode, both when pickling and unpickling.)
Protocol 1 is more efficient than protocol 0; protocol 2 is more
efficient than protocol 1.
Specifying a negative protocol version selects the highest protocol
version supported. The higher the protocol used, the more recent the
version of Python needed to read the pickle produced.
The file parameter must have a write() method that accepts a single
string argument. It can thus be an open file object, a StringIO object,
or any other custom object that meets this interface.
|