MCPcopy Create free account
hub / github.com/LaihoE/Python-demoparser / to_py_array

Function to_py_array

src/lib.rs:38–53  ·  view source on GitHub ↗

https://github.com/pola-rs/polars/blob/master/examples/python_rust_compiled_function/src/ffi.rs

(py: Python, pyarrow: &PyModule, array: ArrayRef)

Source from the content-addressed store, hash-verified

36
37/// https://github.com/pola-rs/polars/blob/master/examples/python_rust_compiled_function/src/ffi.rs
38pub(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
55pub fn rust_series_to_py_series(series: &Series) -> PyResult<PyObject> {
56 let series = series.rechunk();

Callers 1

rust_series_to_py_seriesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected