vibhatha commented on a change in pull request #11993:
URL: https://github.com/apache/arrow/pull/11993#discussion_r786540742
##########
File path: python/pyarrow/array.pxi
##########
@@ -988,13 +988,51 @@ cdef class Array(_PandasConvertible):
def nbytes(self):
"""
Total number of bytes consumed by the elements of the array.
+
+ In other words, the sum of bytes from all buffer
+ ranges referenced.
+
+ Unlike `get_total_buffer_size` this method will account for array
+ offsets.
+
+ If buffers are shared between arrays then the shared
+ portion will be counted multiple times.
+
+ The dictionary of dictionary arrays will always be counted in their
+ entirety even if the array only references a portion of the dictionary.
"""
- size = 0
- for buf in self.buffers():
- if buf is not None:
- size += buf.size
+ cdef:
+ shared_ptr[CArray] shd_ptr_c_array
+ CArray *c_array
+ CResult[int64_t] c_res_buffer
+
+ shd_ptr_c_array = pyarrow_unwrap_array(self)
+ c_array = shd_ptr_c_array.get()
Review comment:
Yes, I also thought about that, but still used that API. :)
I will modify the corresponding calls in rest of the functions.
--
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]