@@ -110,7 +110,7 @@ advantage of using printable ASCII (and of some other characteristics of
110110:mod: `pickle `'s representation) is that for debugging or recovery purposes it is
111111possible for a human to read the pickled file with a standard text editor.
112112
113- There are currently 3 different protocols which can be used for pickling.
113+ There are currently 4 different protocols which can be used for pickling.
114114
115115* Protocol version 0 is the original ASCII protocol and is backwards compatible
116116 with earlier versions of Python.
@@ -121,11 +121,14 @@ There are currently 3 different protocols which can be used for pickling.
121121* Protocol version 2 was introduced in Python 2.3. It provides much more
122122 efficient pickling of :term: `new-style class `\e s.
123123
124+ * Protocol version 3 was added in Python 3.0. It has explicit support for
125+ bytes and cannot be unpickled by Python 2.x pickle modules.
126+
124127Refer to :pep: `307 ` for more information.
125128
126- If a *protocol * is not specified, protocol 0 is used. If *protocol * is specified
127- as a negative value or :const: `HIGHEST_PROTOCOL `, the highest protocol version
128- available will be used.
129+ If a *protocol * is not specified, protocol 3 is used. If *protocol * is
130+ specified as a negative value or :const: `HIGHEST_PROTOCOL `, the highest
131+ protocol version available will be used.
129132
130133A binary format, which is slightly more efficient, can be chosen by specifying a
131134*protocol * version >= 1.
@@ -164,9 +167,9 @@ process more convenient:
164167 Write a pickled representation of *obj * to the open file object *file *. This is
165168 equivalent to ``Pickler(file, protocol).dump(obj) ``.
166169
167- If the *protocol * parameter is omitted, protocol 0 is used. If *protocol * is
168- specified as a negative value or :const: `HIGHEST_PROTOCOL `, the highest protocol
169- version will be used.
170+ If the *protocol * parameter is omitted, protocol 3 is used. If *protocol * is
171+ specified as a negative value or :const: `HIGHEST_PROTOCOL `, the highest
172+ protocol version will be used.
170173
171174 *file * must have a :meth: `write ` method that accepts a single string argument.
172175 It can thus be a file object opened for writing, a :mod: `StringIO ` object, or
@@ -194,9 +197,9 @@ process more convenient:
194197 Return the pickled representation of the object as a string, instead of writing
195198 it to a file.
196199
197- If the *protocol * parameter is omitted, protocol 0 is used. If *protocol * is
198- specified as a negative value or :const: `HIGHEST_PROTOCOL `, the highest protocol
199- version will be used.
200+ If the *protocol * parameter is omitted, protocol 3 is used. If *protocol *
201+ is specified as a negative value or :const: `HIGHEST_PROTOCOL `, the highest
202+ protocol version will be used.
200203
201204
202205.. function :: loads(string)
@@ -234,7 +237,7 @@ The :mod:`pickle` module also exports two callables [#]_, :class:`Pickler` and
234237
235238 This takes a file-like object to which it will write a pickle data stream.
236239
237- If the *protocol * parameter is omitted, protocol 0 is used. If *protocol * is
240+ If the *protocol * parameter is omitted, protocol 3 is used. If *protocol * is
238241 specified as a negative value or :const: `HIGHEST_PROTOCOL `, the highest
239242 protocol version will be used.
240243
@@ -681,8 +684,8 @@ that a self-referencing list is pickled and restored correctly. ::
681684
682685 output = open('data.pkl', 'wb')
683686
684- # Pickle dictionary using protocol 0 .
685- pickle.dump(data1, output)
687+ # Pickle dictionary using protocol 2 .
688+ pickle.dump(data1, output, 2 )
686689
687690 # Pickle the list using the highest protocol available.
688691 pickle.dump(selfref_list, output, -1)
0 commit comments