| 394 | /// Save a Python object by pickling it. |
| 395 | template<typename Archiver> |
| 396 | void |
| 397 | save_impl(Archiver& ar, const boost::python::object& obj, |
| 398 | const unsigned int /*version*/, |
| 399 | mpl::false_ /*has_direct_serialization*/) |
| 400 | { |
| 401 | boost::python::str py_string = boost::python::pickle::dumps(obj); |
| 402 | int len = boost::python::extract<int>(py_string.attr("__len__")()); |
| 403 | const char* string = boost::python::extract<const char*>(py_string); |
| 404 | ar << len << boost::serialization::make_array(string, len); |
| 405 | } |
| 406 | |
| 407 | /// Try to save a Python object by directly serializing it; fall back |
| 408 | /// on pickling if required. |
no test coverage detected