Deserialize protobuf buffer in Python from C++ with pybind11
问题 I have a char *buffer which I convert to a C++ string std::string sbuffer(buffer); because I want to pass it to python. C++ can work with: protoObj.ParseFromArray(buffer, sbuffer.size()); I pass the buffer to python via: py::scoped_interpreter python; py::module calc = py::module::import("Calculation"); py::object Calculation = calc.attr("Calculation"); py::object calculation = Calculation(); calculation.attr("funcName")(sbuffer.data(), sbuffer.size()); The python file looks kinda like this: