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


##########
python/pyarrow/io.pxi:
##########
@@ -395,6 +395,42 @@ cdef class NativeFile(_Weakrefable):
 
         return PyObject_to_object(obj)
 
+    def get_stream(self, file_offset, nbytes):
+        """
+        Returns an input stream that reads a file segment independent of the
+        state of the file.

Review Comment:
   Nit:
   ```suggestion
           Return an input stream that reads a file segment independent of the
           state of the file.
   ```



##########
python/pyarrow/io.pxi:
##########
@@ -395,6 +395,42 @@ cdef class NativeFile(_Weakrefable):
 
         return PyObject_to_object(obj)
 
+    def get_stream(self, file_offset, nbytes):

Review Comment:
   This implementation seems basically correct to me, thanks.



##########
python/pyarrow/io.pxi:
##########
@@ -395,6 +395,42 @@ cdef class NativeFile(_Weakrefable):
 
         return PyObject_to_object(obj)
 
+    def get_stream(self, file_offset, nbytes):
+        """
+        Returns an input stream that reads a file segment independent of the
+        state of the file.
+
+        Allows reading portions of a random access file as an input stream
+        without interfering with each other.
+
+        Parameters
+        ----------
+        file_offset : int
+        nbytes : int
+
+        Returns
+        -------
+        stream : bytes

Review Comment:
   The annotation here is incorrect, should be something like:
   ```suggestion
           stream : NativeFile
   ```



##########
python/pyarrow/tests/test_io.py:
##########
@@ -125,6 +125,24 @@ def test_python_file_read():
         pa.PythonFile(StringIO(), mode='r')
 
 
+def test_python_file_get_stream():

Review Comment:
   The tests would deserve expanding a bit:
   * test what happens when reading past the of stream
   * test what happens when `file_offset` and `nbytes` are slightly out of 
bounds
   



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