FromPyObject
FromPyObject is a trait in PyO3, the Rust binding for Python, that defines how to convert a Python object into a Rust value. The trait is parameterized with a lifetime (FromPyObject<'source>) and requires an extract function that receives a reference to a Python object (typically a PyAny) and returns a PyResult<Self>. Implementations exist for common Rust types such as integers, floats, booleans, and strings, as well as compound types like Vec<T> and Option<T> when T: FromPyObject.
In practice, PyO3 provides a convenient method on Python objects called extract that uses the FromPyObject
Key considerations include the lifetime aspect: the extracted value borrows from the original Python object, so