Function pyo3::marshal::dumps_bound

source ·
pub fn dumps_bound<'py>(
    py: Python<'py>,
    object: &impl AsPyPointer,
    version: i32
) -> PyResult<Bound<'py, PyBytes>>
Available on non-Py_LIMITED_API only.
Expand description

Serialize an object to bytes using the Python built-in marshal module.

The built-in marshalling only supports a limited range of objects. The exact types supported depend on the version argument. The VERSION constant holds the highest version currently supported.

See the Python documentation for more details.

§Examples

let dict = PyDict::new_bound(py);
dict.set_item("aap", "noot").unwrap();
dict.set_item("mies", "wim").unwrap();
dict.set_item("zus", "jet").unwrap();

let bytes = marshal::dumps_bound(py, &dict, marshal::VERSION);
⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here