alamb commented on code in PR #10155:
URL: https://github.com/apache/arrow-rs/pull/10155#discussion_r3454312975


##########
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 fine -- I mostly have seen that the collect syntax can be faster in 
some cases (e.g. the capacity check in `push` can be optimized away).
   
   



-- 
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]

Reply via email to