From 4972d0687e06d10f07a4420f909139da492aed9a Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 12 Sep 2024 11:27:12 -0400 Subject: [PATCH] Simplify by getting rid of intermediate Series. --- crates/polars-core/src/series/arithmetic/borrowed.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/polars-core/src/series/arithmetic/borrowed.rs b/crates/polars-core/src/series/arithmetic/borrowed.rs index 9904a440fa18..39b560311d84 100644 --- a/crates/polars-core/src/series/arithmetic/borrowed.rs +++ b/crates/polars-core/src/series/arithmetic/borrowed.rs @@ -260,7 +260,8 @@ impl ListChunked { let combined = self.amortized_iter().zip(rhs.list()?.amortized_iter()).map(|(a, b)| { let (Some(a_owner), Some(b_owner)) = (a, b) else { // Operations with nulls always result in nulls: - return Ok(Series::full_null(self.name().clone(), 1, self.dtype())); + let inner_dtype = self.dtype().inner_dtype().unwrap(); + return Ok(ListChunked::full_null_with_dtype(self.name().clone(), 1, inner_dtype)); }; let a = a_owner.as_ref(); let b = b_owner.as_ref(); @@ -281,10 +282,10 @@ impl ListChunked { } else { op(a, b) }; - chunk_result.and_then(|s| s.implode()).map(Series::from) + chunk_result.and_then(|s| s.implode()) }); for c in combined.into_iter() { - result.append(c?.list()?)?; + result.append(&c?)?; } return Ok(result.into()); }