uros-b commented on code in PR #50561:
URL: https://github.com/apache/arrow/pull/50561#discussion_r3658680367
##########
python/pyarrow/table.pxi:
##########
@@ -555,8 +555,9 @@ cdef class ChunkedArray(_PandasConvertible):
"If using `np.array(obj, copy=False)` replace it with "
"`np.asarray(obj)` to allow a copy when needed"
)
- # 'copy' can further be ignored because to_numpy() already returns a
copy
values = self.to_numpy()
+ if copy is True:
+ return np.array(values, dtype=dtype, copy=True)
Review Comment:
Please note: for multi-chunk or has-nulls arrays, to_numpy() already returns
a fresh copy, then np.array(values, copy=True) copies it again unnecessarily.
For example, the sibling `Array.__array__` (in array.pxi) avoids this by
guarding the extra copy:
```
if copy is True and is_numeric(self.type.id) and self.null_count == 0:
return np.array(values, dtype=dtype, copy=True)
```
however, doing that here might be a bit involved - in that case, it's
probably fine to leave as-is.
--
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]