@@ -813,26 +813,21 @@ An instance can now be pickled as follows:
813813
814814.. code-block :: python
815815
816- try :
817- import cPickle as pickle # Use cPickle on Python 2.7
818- except ImportError :
819- import pickle
816+ import pickle
820817
821818 p = Pickleable(" test_value" )
822819 p.setExtra(15 )
823- data = pickle.dumps(p, 2 )
820+ data = pickle.dumps(p)
824821
825822
826823 .. note ::
827- Note that only the cPickle module is supported on Python 2.7.
828-
829- The second argument to ``dumps `` is also crucial: it selects the pickle
830- protocol version 2, since the older version 1 is not supported. Newer
831- versions are also fine—for instance, specify ``-1 `` to always use the
832- latest available version. Beware: failure to follow these instructions
833- will cause important pybind11 memory allocation routines to be skipped
834- during unpickling, which will likely lead to memory corruption and/or
835- segmentation faults.
824+ If given, the second argument to ``dumps `` must be 2 or larger - 0 and 1 are
825+ not supported. Newer versions are also fine; for instance, specify ``-1 `` to
826+ always use the latest available version. Beware: failure to follow these
827+ instructions will cause important pybind11 memory allocation routines to be
828+ skipped during unpickling, which will likely lead to memory corruption
829+ and/or segmentation faults. Python defaults to version 3 (Python 3-3.7) and
830+ version 4 for Python 3.8+.
836831
837832.. seealso ::
838833
@@ -849,11 +844,9 @@ Python normally uses references in assignments. Sometimes a real copy is needed
849844to prevent changing all copies. The ``copy `` module [#f5 ]_ provides these
850845capabilities.
851846
852- On Python 3, a class with pickle support is automatically also (deep)copy
847+ A class with pickle support is automatically also (deep)copy
853848compatible. However, performance can be improved by adding custom
854- ``__copy__ `` and ``__deepcopy__ `` methods. With Python 2.7, these custom methods
855- are mandatory for (deep)copy compatibility, because pybind11 only supports
856- cPickle.
849+ ``__copy__ `` and ``__deepcopy__ `` methods.
857850
858851For simple classes (deep)copy can be enabled by using the copy constructor,
859852which should look as follows:
0 commit comments