MCPcopy Index your code
hub / github.com/davidhewitt/pythonize / depythonize

Function depythonize

src/de.rs:21–26  ·  view source on GitHub ↗

Attempt to convert a Python object to an instance of `T`. Generally this only supports Python types that match `serde`'s object model well: - integers (including arbitrary precision integers if the `arbitrary_precision` feature is enabled) - floats - strings - bytes - `collections.abc.Sequence` instances (as serde sequences) - `collections.abc.Mapping` instances (as serde maps) - dataclasses (as

(obj: &'a Bound<'py, PyAny>)

Source from the content-addressed store, hash-verified

19/// - `collections.abc.Mapping` instances (as serde maps)
20/// - dataclasses (as serde maps)
21pub fn depythonize<'a, 'py, T>(obj: &'a Bound<'py, PyAny>) -> Result<T>
22where
23 T: Deserialize<'a>,
24{
25 T::deserialize(&mut Depythonizer::from_object(obj))
26}
27
28/// A structure that deserializes Python objects into Rust values
29pub struct Depythonizer<'a, 'py> {

Callers 15

test_de_with_objFunction · 0.85
test_int_limitsFunction · 0.85
test_deserialize_bytesFunction · 0.85
test_dataclassFunction · 0.85
test_custom_listFunction · 0.85
test_custom_dictFunction · 0.85
test_tupleFunction · 0.85
test_custom_unnamed_dictFunction · 0.85
test_custom_named_dictFunction · 0.85
test_simple_round_tripFunction · 0.85

Calls

no outgoing calls

Tested by 15

test_de_with_objFunction · 0.68
test_int_limitsFunction · 0.68
test_deserialize_bytesFunction · 0.68
test_dataclassFunction · 0.68
test_custom_listFunction · 0.68
test_custom_dictFunction · 0.68
test_tupleFunction · 0.68
test_custom_unnamed_dictFunction · 0.68
test_custom_named_dictFunction · 0.68
test_simple_round_tripFunction · 0.68