paleolimbot commented on code in PR #340:
URL: https://github.com/apache/arrow-nanoarrow/pull/340#discussion_r1447970333
##########
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):
Review Comment:
I think a higher-level (not C) `Schema` is where I was headed with this
change, which would basically be a `CSchema` with a cached `SchemaView`
implemented in Python. (Also for consistency with creating an array view).
--
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]