paleolimbot commented on code in PR #340:
URL: https://github.com/apache/arrow-nanoarrow/pull/340#discussion_r1447977420


##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -352,57 +326,45 @@ cdef class Schema:
     def metadata(self):
         self._assert_valid()
         if self._ptr.metadata != NULL:
-            return SchemaMetadata(self, <uintptr_t>self._ptr.metadata)
+            return SchemaMetadata(self._base, <uintptr_t>self._ptr.metadata)
         else:
             return None
 
     @property
-    def children(self):
+    def n_children(self):
+        self._assert_valid()
+        return self._ptr.n_children
+
+    def child(self, int64_t i):
         self._assert_valid()
-        return SchemaChildren(self)
+        if i < 0 or i >= self._ptr.n_children:
+            raise IndexError(f"{i} out of range [0, {self._ptr.n_children})")
+
+        return CSchema(self._base, <uintptr_t>self._ptr.children[i])
+
+    @property
+    def children(self):
+        for i in range(self.n_children):
+            yield self.child(i)
 
     @property
     def dictionary(self):
         self._assert_valid()
         if self._ptr.dictionary != NULL:
-            return Schema(self, <uintptr_t>self._ptr.dictionary)
+            return CSchema(self, <uintptr_t>self._ptr.dictionary)
         else:
             return None
 
-    def view(self):
-        self._assert_valid()
-        schema_view = SchemaView()
-        cdef Error error = Error()
-        cdef int result = ArrowSchemaViewInit(&schema_view._schema_view, 
self._ptr, &error.c_error)
-        if result != NANOARROW_OK:
-            error.raise_message("ArrowSchemaViewInit()", result)
 
-        return schema_view
+cdef class CSchemaView:
+    """Low-level ArrowSchemaView wrapper
 
+    This object is a literal wrapper around a read-only ArrowSchema. It 
provides field accessors
+    that return Python objects and handles structure lifecycle.
 
-cdef class SchemaView:
-    """ArrowSchemaView wrapper
-
-    The ArrowSchemaView is a nanoarrow C library structure that facilitates
-    access to the deserialized content of an ArrowSchema (e.g., parameter
-    values for parameterized types). This wrapper extends that facility to 
Python.
-
-    Examples
-    --------
-
-    >>> import pyarrow as pa
-    >>> import nanoarrow as na
-    >>> schema = na.schema(pa.decimal128(10, 3))
-    >>> schema_view = schema.view()
-    >>> schema_view.type
-    'decimal128'
-    >>> schema_view.decimal_bitwidth
-    128
-    >>> schema_view.decimal_precision
-    10
-    >>> schema_view.decimal_scale
-    3
+    See `nanoarrow.c_schema_view()` for construction and usage examples.
     """
+    cdef object _base

Review Comment:
   I added a comment...it could possibly be something else (although may never 
be).



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