Skip to content

Commit

Permalink
Simplify by getting rid of intermediate Series.
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed committed Sep 12, 2024
1 parent 19650ab commit 4972d06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/polars-core/src/series/arithmetic/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
}
Expand Down

0 comments on commit 4972d06

Please sign in to comment.