danepitkin commented on code in PR #433:
URL: https://github.com/apache/arrow-nanoarrow/pull/433#discussion_r1576882392


##########
python/src/nanoarrow/array.py:
##########
@@ -244,23 +270,25 @@ def buffers(self) -> Tuple[CBuffer]:
         view = c_array_view(self)
         return tuple(view.buffers)
 
-    def iter_buffers(self) -> Iterable[Tuple[CBuffer]]:
-        """Iterate over buffers of each chunk in this Array.
+    def iter_chunk_data(self) -> Iterable[CArrayView]:
+        """Iterate over Iterate over prepared views of each chunk

Review Comment:
   ```suggestion
           """Iterate over prepared views of each chunk
   ```



##########
python/src/nanoarrow/array.py:
##########
@@ -244,23 +270,25 @@ def buffers(self) -> Tuple[CBuffer]:
         view = c_array_view(self)
         return tuple(view.buffers)
 
-    def iter_buffers(self) -> Iterable[Tuple[CBuffer]]:
-        """Iterate over buffers of each chunk in this Array.
+    def iter_chunk_data(self) -> Iterable[CArrayView]:

Review Comment:
   This sounds similar to `iter_chunks`. Is there a better way to differentiate 
the two APIs? Maybe call this one `iter_chunk_views`?



##########
python/src/nanoarrow/array.py:
##########
@@ -214,8 +221,27 @@ def n_buffers(self) -> int:
         """
         return self.schema._c_schema_view.layout.n_buffers
 
+    @property
+    def offset(self) -> int:
+        """Access the logical offset of a contiguous array
+
+        Examples
+        --------
+
+        >>> import nanoarrow as na
+        >>> c_array = na.c_array([1, 2, 3], na.int32())
+        >>> na.Array(c_array[1:]).offset
+        1
+        """
+        if self._data.n_arrays == 0:
+            return 0
+        elif self._data.n_arrays == 1:
+            return self._data.array(0).offset
+
+        self._assert_one_chunk("scalar offset")

Review Comment:
   For readability, I recommend reorganizing as:
   ```suggestion
           if self._data.n_arrays == 0:
               return 0
           self._assert_one_chunk("scalar offset")
           return self._data.array(0).offset
   ```



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