pitrou commented on code in PR #37797:
URL: https://github.com/apache/arrow/pull/37797#discussion_r1339102230


##########
python/pyarrow/tests/test_cffi.py:
##########
@@ -411,3 +411,131 @@ def test_imported_batch_reader_error():
                        match="Expected to be able to read 16 bytes "
                              "for message body, got 8"):
         reader_new.read_all()
+
+
[email protected]('obj', [pa.int32(), pa.field('foo', pa.int32()),
+                                 pa.schema({'foo': pa.int32()})],
+                         ids=['type', 'field', 'schema'])
+def test_roundtrip_schema_capsule(obj):
+    gc.collect()  # Make sure no Arrow data dangles in a ref cycle
+    old_allocated = pa.total_allocated_bytes()
+
+    capsule = obj.__arrow_c_schema__()
+    assert type(capsule).__name__ == "PyCapsule"
+    assert '"arrowschema"' in repr(capsule)

Review Comment:
   Ah! Either we install it through pip, or you can just use `ctypes.pythonapi` 
to access the PyCapsule APIs (but you need to declare their signatures 
explicitly).
   
https://docs.python.org/3/library/ctypes.html#accessing-values-exported-from-dlls



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