Tpt commented on code in PR #10155:
URL: https://github.com/apache/arrow-rs/pull/10155#discussion_r3438593073
##########
arrow-pyarrow/src/lib.rs:
##########
@@ -321,18 +321,20 @@ impl ToPyArrow for ArrayData {
impl<T: FromPyArrow> FromPyArrow for Vec<T> {
fn from_pyarrow_bound(value: &Bound<PyAny>) -> PyResult<Self> {
- let list = value.cast::<PyList>()?;
- list.iter().map(|x| T::from_pyarrow_bound(&x)).collect()
+ let mut v = Vec::with_capacity(value.len().unwrap_or(0));
Review Comment:
This is a micro-opt to pre-allocate the `Vec` at the expected size.
`.collect()` won't have a visibility on it because of `PyAny::try_iter`. Glad
to revert if you prefer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]