pitrou commented on code in PR #39980:
URL: https://github.com/apache/arrow/pull/39980#discussion_r1499398699
##########
python/pyarrow/tests/test_cffi.py:
##########
@@ -627,3 +627,115 @@ def
test_roundtrip_chunked_array_capsule_requested_schema():
requested_capsule = requested_type.__arrow_c_schema__()
with pytest.raises(NotImplementedError):
chunked.__arrow_c_stream__(requested_capsule)
+
+
+@needs_cffi
+def test_export_import_device_array():
Review Comment:
We're copy-pasting a lot of code in those tests, can we try to reduce
duplication by factoring common functionality out?
##########
python/pyarrow/array.pxi:
##########
@@ -1778,6 +1778,70 @@ cdef class Array(_PandasConvertible):
return pyarrow_wrap_array(array)
+ def _export_to_c_device(self, out_ptr, out_schema_ptr=0):
Review Comment:
`out_schema_ptr=None` would feel slightly more Pythonic IMHO, though that's
debatable.
##########
python/pyarrow/array.pxi:
##########
@@ -1778,6 +1778,70 @@ cdef class Array(_PandasConvertible):
return pyarrow_wrap_array(array)
+ def _export_to_c_device(self, out_ptr, out_schema_ptr=0):
+ """
+ Export to a C ArrowDeviceArray struct, given its pointer.
+
+ If a C ArrowSchema struct pointer is also given, the array type
+ is exported to it at the same time.
+
+ Parameters
+ ----------
+ out_ptr: int
+ The raw pointer to a C ArrowDeviceArray struct.
+ out_schema_ptr: int (optional)
+ The raw pointer to a C ArrowSchema struct.
+
+ Be careful: if you don't pass the ArrowDeviceArray struct to a
consumer,
+ array memory will leak. This is a low-level function intended for
+ expert users.
Review Comment:
I agree with @jorisvandenbossche that the release callback need not be
mentioned here. This is all in the spec.
--
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]