pub(crate) fn to_py_array(
    py: Python,
    pyarrow: &Bound<PyModule>,
    array: ArrayRef,
) -> PyResult<PyObject> {
    let schema = Box::new(ffi::export_field_to_c(&ArrowField::new(
        "",
        array.data_type().clone(),
        true,
    )));
    let array = Box::new(ffi::export_array_to_c(array));

    let schema_ptr: *const ffi::ArrowSchema = &*schema;
    let array_ptr: *const ffi::ArrowArray = &*array;

    let array = pyarrow.getattr("Array")?.call_method1(
        "_import_from_c",
        (array_ptr as Py_uintptr_t, schema_ptr as Py_uintptr_t),
    )?;

    Ok(array.to_object(py))
}
<https://github.com/pola-rs/polars/blob/master/examples/python_rust_compiled_function/src/ffi.rs>
src/python/src/lib.rs