void add_serialization()

in include/quantile_conditional.hpp [60:76]


void add_serialization(nb::class_<SK>& clazz) {
  clazz.def(
        "serialize",
        [](const SK& sk, datasketches::py_object_serde& serde) {
          auto bytes = sk.serialize(0, serde);
          return nb::bytes(reinterpret_cast<const char*>(bytes.data()), bytes.size());
        }, nb::arg("serde"),
        "Serializes the sketch into a bytes object using the provided serde."
    )
    .def_static(
        "deserialize",
        [](const nb::bytes& bytes, datasketches::py_object_serde& serde) {
            return SK::deserialize(bytes.c_str(), bytes.size(), serde);
        }, nb::arg("bytes"), nb::arg("serde"),
        "Deserializes the sketch from a bytes object using the provided serde."
    );
}