https://github.com/pola-rs/polars/blob/master/examples/python_rust_compiled_function/src/ffi.rs
(py: Python, pyarrow: &PyModule, array: ArrayRef)
| 36 | |
| 37 | /// https://github.com/pola-rs/polars/blob/master/examples/python_rust_compiled_function/src/ffi.rs |
| 38 | pub(crate) fn to_py_array(py: Python, pyarrow: &PyModule, array: ArrayRef) -> PyResult<PyObject> { |
| 39 | let schema = Box::new(ffi::export_field_to_c(&ArrowField::new( |
| 40 | "", |
| 41 | array.data_type().clone(), |
| 42 | true, |
| 43 | ))); |
| 44 | let array = Box::new(ffi::export_array_to_c(array)); |
| 45 | let schema_ptr: *const ffi::ArrowSchema = &*schema; |
| 46 | let array_ptr: *const ffi::ArrowArray = &*array; |
| 47 | let array = pyarrow.getattr("Array")?.call_method1( |
| 48 | "_import_from_c", |
| 49 | (array_ptr as Py_uintptr_t, schema_ptr as Py_uintptr_t), |
| 50 | )?; |
| 51 | |
| 52 | Ok(array.to_object(py)) |
| 53 | } |
| 54 | /// https://github.com/pola-rs/polars/blob/master/examples/python_rust_compiled_function/src/ffi.rs |
| 55 | pub fn rust_series_to_py_series(series: &Series) -> PyResult<PyObject> { |
| 56 | let series = series.rechunk(); |
no outgoing calls
no test coverage detected