Copilot commented on code in PR #41709:
URL: https://github.com/apache/arrow/pull/41709#discussion_r4123095951
##########
python/pyarrow/types.py:
##########
@@ -257,7 +253,7 @@ def is_union(t):
@doc(is_null, datatype="nested type")
def is_nested(t):
- return t.id in _NESTED_TYPES
+ return lib._is_nested(t)
Review Comment:
To match `_is_primitive` (and to avoid relying on `lib._is_nested` doing a
Python `.id` lookup), pass the type id to the Cython helper and keep the helper
signature typed as `Type`.
##########
python/pyarrow/types.pxi:
##########
@@ -161,6 +161,11 @@ def _is_primitive(Type type):
return is_primitive(type)
+def _is_nested(data_type):
+ # This is simply a redirect, the official API is in pyarrow.types.
+ return is_nested(data_type.id)
+
Review Comment:
`_is_nested` takes a Python object and accesses `.id` inside Cython, which
is inconsistent with `_is_primitive(Type type)` above and adds extra Python
attribute lookup. Consider accepting a `Type` directly and forwarding it to the
C++ `is_nested` trait, mirroring the existing pattern.
--
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]