mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
clarified pickling docs
This commit is contained in:
parent
3d0e6fff25
commit
d40885a1e6
@ -1225,7 +1225,8 @@ looks as follows:
|
|||||||
if (t.size() != 2)
|
if (t.size() != 2)
|
||||||
throw std::runtime_error("Invalid state!");
|
throw std::runtime_error("Invalid state!");
|
||||||
|
|
||||||
/* Invoke the constructor (need to use in-place version) */
|
/* Invoke the in-place constructor. Note that this is needed even
|
||||||
|
when the object just has a trivial default constructor */
|
||||||
new (&p) Pickleable(t[0].cast<std::string>());
|
new (&p) Pickleable(t[0].cast<std::string>());
|
||||||
|
|
||||||
/* Assign any additional state */
|
/* Assign any additional state */
|
||||||
@ -1247,7 +1248,9 @@ An instance can now be pickled as follows:
|
|||||||
|
|
||||||
Note that only the cPickle module is supported on Python 2.7. It is also
|
Note that only the cPickle module is supported on Python 2.7. It is also
|
||||||
important to request usage of the highest protocol version using the ``-1``
|
important to request usage of the highest protocol version using the ``-1``
|
||||||
argument to ``dumps``.
|
argument to ``dumps``. Failure to follow these two steps will lead to important
|
||||||
|
pybind11 memory allocation routines to be skipped during unpickling, which will
|
||||||
|
likely cause memory corruption and/or segmentation faults.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user