pitrou commented on code in PR #37797:
URL: https://github.com/apache/arrow/pull/37797#discussion_r1345656393
##########
python/pyarrow/array.pxi:
##########
@@ -1699,6 +1711,81 @@ cdef class Array(_PandasConvertible):
c_type))
return pyarrow_wrap_array(c_array)
+ def __arrow_c_array__(self, requested_schema=None):
+ """
+ Get a pair of PyCapsules containing a C ArrowArray representation of
the object.
+
+ Parameters
+ ----------
+ requested_schema : PyCapsule | None
+ A PyCapsule containing a C ArrowSchema representation of a
requested
+ schema. PyArrow will attempt to cast the array to this data type.
+ If None, the array will be returned as-is, with a type matching the
+ one returned by :meth:`__arrow_c_schema__()`.
+
+ Returns
+ -------
+ Tuple[PyCapsule, PyCapsule]
+ A pair of PyCapsules containing a C ArrowSchema and ArrowArray,
+ respectively.
+ """
+ cdef:
+ ArrowArray* c_array = <ArrowArray*> malloc(sizeof(ArrowArray))
+ ArrowSchema* c_schema = <ArrowSchema*> malloc(sizeof(ArrowSchema))
Review Comment:
Doing the mallocs here implies a memory leak (albeit minor) if we raise an
exception without creating the capsules.
--
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]