jorisvandenbossche commented on code in PR #40356:
URL: https://github.com/apache/arrow/pull/40356#discussion_r1584266480


##########
python/pyarrow/_fs.pyx:
##########
@@ -1097,30 +1101,18 @@ cdef class LocalFileSystem(FileSystem):
 
     def __init__(self, *, use_mmap=False):
         cdef:
-            CLocalFileSystemOptions opts
-            shared_ptr[CLocalFileSystem] fs
-
-        opts = CLocalFileSystemOptions.Defaults()
-        opts.use_mmap = use_mmap
+            shared_ptr[CFileSystem] fs
+            c_string c_uri
 
-        fs = make_shared[CLocalFileSystem](opts)
+        # from_uri needs a non-empty path, so just use a placeholder of /_
+        c_uri = tobytes(f"file:///_?use_mmap={int(use_mmap)}")
+        with nogil:
+            fs = GetResultValue(CFileSystemFromUri(c_uri))
         self.init(<shared_ptr[CFileSystem]> fs)
 
-    cdef init(self, const shared_ptr[CFileSystem]& c_fs):
-        FileSystem.init(self, c_fs)
-        self.localfs = <CLocalFileSystem*> c_fs.get()
-
-    @staticmethod
-    @binding(True)  # Required for cython < 3
-    def _reconstruct(kwargs):
-        # __reduce__ doesn't allow passing named arguments directly to the
-        # reconstructor, hence this wrapper.
-        return LocalFileSystem(**kwargs)
-
     def __reduce__(self):
-        cdef CLocalFileSystemOptions opts = self.localfs.options()
-        return LocalFileSystem._reconstruct, (dict(
-            use_mmap=opts.use_mmap),)
+        uri = frombytes(GetResultValue(self.fs.MakeUri(b"/_")))
+        return FileSystem._from_uri, (uri,)

Review Comment:
   Refactoring this has broken the cython-2 build (as the removed comments 
indicated, that code was required for cython < 3)
   
   See 
https://github.com/ursacomputing/crossbow/actions/runs/8887296743/job/24402368974
   
   (TBH, I would personally also fine with just dropping that build and 
requiring cython > 3 for building)



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