jorisvandenbossche commented on code in PR #313:
URL: https://github.com/apache/arrow-nanoarrow/pull/313#discussion_r1395668583


##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -474,20 +481,8 @@ cdef class Array:
         else:
             return None
 
-    def view(self):

Review Comment:
   Is there a reason you are making this into a function instead of method? 
(for Schema it's still a method, so this gets a bit inconsistent)



##########
python/src/nanoarrow/_lib_utils.py:
##########
@@ -0,0 +1,91 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# The functions here are imported in _lib.pyx. They're defined here
+# instead of there to make it easier to iterate (no need to rebuild
+# after editing when working with an editable installation)
+
+
+def schema_repr(schema, indent=0):
+    indent_str = " " * indent
+    if schema._addr() == 0:
+        return "<NULL nanoarrow.Schema>"
+    elif not schema.is_valid():
+        return "<released nanoarrow.Schema>"
+
+    lines = [f"<nanoarrow.Schema {schema._to_string()}>"]
+
+    for attr in ("format", "name", "flags"):
+        attr_repr = repr(getattr(schema, attr))
+        lines.append(f"{indent_str}- {attr}: {attr_repr}")
+
+    metadata = schema.metadata
+    if schema.metadata is None:
+        lines.append(f"{indent_str}- metadata: NULL")
+    else:
+        lines.append(f"{indent_str}- metadata: NULL")

Review Comment:
   ```suggestion
           lines.append(f"{indent_str}- metadata:")
   ```



##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -903,3 +943,112 @@ cdef class ArrayStream:
     def allocate():
         base = ArrayStreamHolder()
         return ArrayStream(base, base._addr())
+
+
+cdef class DeviceArrayHolder:
+    """Memory holder for an ArrowDeviceArray
+
+    This class is responsible for the lifecycle of the ArrowDeviceArray
+    whose memory it is responsible. When this object is deleted,
+    a non-NULL release callback is invoked.
+    """
+    cdef ArrowDeviceArray c_array
+
+    def __cinit__(self):
+        self.c_array.array.release = NULL
+
+    def __dealloc__(self):
+        if self.c_array.array.release != NULL:
+          self.c_array.array.release(&self.c_array.array)
+
+    def _addr(self):
+        return <uintptr_t>&self.c_array
+
+cdef class DeviceHolder:
+    """Memory holder for an ArrowDevice

Review Comment:
   Is this ArrowDevice concept something specific from nanoarrow? (I don't find 
it in https://arrow.apache.org/docs/dev/format/CDeviceDataInterface.html)



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