We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
needed for python frontend like dataiku, which stores python model using pickle... pybind11 should provide most of api :
py::class_<Archive>(m, "Archive") .def(py::pickle( [](const Archive& a) { // dump return py::make_tuple(a.member1, a.member2, a.member3); }, [](py::tuple t) { // load return Archive{t[0].cast<T>(), t[1].cast<T>(), t[2].cast<T>()}; } ));
The text was updated successfully, but these errors were encountered:
more details in https://pybind11.readthedocs.io/en/stable/advanced/classes.html
py::class_<Pickleable>(m, "Pickleable") .def(py::init<std::string>()) .def("value", &Pickleable::value) .def("extra", &Pickleable::extra) .def("setExtra", &Pickleable::setExtra) .def(py::pickle( [](const Pickleable &p) { // __getstate__ /* Return a tuple that fully encodes the state of the object */ return py::make_tuple(p.value(), p.extra()); }, [](py::tuple t) { // __setstate__ if (t.size() != 2) throw std::runtime_error("Invalid state!"); /* Create a new C++ instance */ Pickleable p(t[0].cast<std::string>()); /* Assign any additional state */ p.setExtra(t[1].cast<int>()); return p; } ));
Sorry, something went wrong.
No branches or pull requests
needed for python frontend like dataiku, which stores python model using pickle...
pybind11 should provide most of api :
The text was updated successfully, but these errors were encountered: