paleolimbot commented on code in PR #586:
URL: https://github.com/apache/arrow-nanoarrow/pull/586#discussion_r1757122899


##########
python/src/nanoarrow/ipc.py:
##########
@@ -236,9 +243,198 @@ def __repr__(self) -> str:
             return f"<{class_label} <invalid>>"
 
 
+class Writer:
+    def __init__(self):
+        self._writer = None
+        self._desc = None
+        self._iterator = None
+
+    def _is_valid(self) -> bool:
+        return self._writer is not None and self._writer.is_valid()
+
+    def __enter__(self):
+        return self
+
+    def __exit__(self, *args, **kwargs):
+        self.close()
+
+    def release(self):
+        """Close stream without writing the end-of-stream marker"""
+        if not self._is_valid():
+            return
+
+        self._writer.release()
+        self._writer = None
+
+    def close(self):
+        """Close stream and write end-of-stream marker"""
+        if not self._is_valid():
+            return
+
+        self._writer.write_end_of_stream()
+        self.release()
+
+    def write_stream(self, obj, schema=None, *, write_schema=None):

Review Comment:
   There could be! An array can be implicitly converted to a stream and will 
work here, but I'll add one for symmetry (and some day it might be faster!)



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