From c2e2144d8d1b48462a1bb9ea64cb759249cf620c Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Tue, 23 Jul 2024 13:42:27 -0400 Subject: [PATCH] Remove clone --- py-polars/src/dataframe/export.rs | 2 +- py-polars/src/interop/arrow/to_py.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/py-polars/src/dataframe/export.rs b/py-polars/src/dataframe/export.rs index f595ac92f02c..cfd6f1406ef2 100644 --- a/py-polars/src/dataframe/export.rs +++ b/py-polars/src/dataframe/export.rs @@ -140,6 +140,6 @@ impl PyDataFrame { requested_schema: Option, ) -> PyResult> { self.df.align_chunks(); - dataframe_to_stream(self.df.clone(), py) + dataframe_to_stream(&self.df, py) } } diff --git a/py-polars/src/interop/arrow/to_py.rs b/py-polars/src/interop/arrow/to_py.rs index 17a89ff1eccc..2581a52f34ce 100644 --- a/py-polars/src/interop/arrow/to_py.rs +++ b/py-polars/src/interop/arrow/to_py.rs @@ -71,7 +71,10 @@ pub(crate) fn series_to_stream<'py>( PyCapsule::new_bound(py, stream, Some(stream_capsule_name)) } -pub(crate) fn dataframe_to_stream(df: DataFrame, py: Python) -> PyResult> { +pub(crate) fn dataframe_to_stream<'py>( + df: &'py DataFrame, + py: Python<'py>, +) -> PyResult> { let iter = Box::new(DataFrameStreamIterator::new(df)); let field = iter.field(); let stream = ffi::export_iterator(iter, field); @@ -87,7 +90,7 @@ pub struct DataFrameStreamIterator { } impl DataFrameStreamIterator { - fn new(df: DataFrame) -> Self { + fn new(df: &DataFrame) -> Self { let schema = df.schema().to_arrow(CompatLevel::newest()); let data_type = ArrowDataType::Struct(schema.fields);