You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Maarten Breddels (Jira)" <ji...@apache.org> on 2020/11/24 13:00:03 UTC
[jira] [Commented] (ARROW-10709) [Python] Difficult to make an
efficient zero-copy file reader in Python
[ https://issues.apache.org/jira/browse/ARROW-10709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17238106#comment-17238106 ]
Maarten Breddels commented on ARROW-10709:
------------------------------------------
Pandas also does not like it when .read returns a memoryview. Maybe a better solution is to try to call a read_buffer method on the Python object (with a fallback to read).
> [Python] Difficult to make an efficient zero-copy file reader in Python
> -----------------------------------------------------------------------
>
> Key: ARROW-10709
> URL: https://issues.apache.org/jira/browse/ARROW-10709
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Python
> Reporter: Maarten Breddels
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> There is an option to do efficient data transport using file.read_buffer() using zero memory copies (benchmarking have confirmed that, very nice!).
> However, file.read_buffer() when backed by a Python object (via PythonFile), will call PythonFile.read() via PyReadableFile::Read. A 'normal' file.read() that does memory copying, also calls the PythonFile.read() method, but only allows for a bytes object (PyBytes_Check is used in PyReadableFile::Read).
> This makes it hard to create 1 file object in Python land that supports normal .read() (and thus needs to returns a bytes object) and to also support a zero-copy route where .read() can return a memory view.
> Possibly the strict check on PyBytes_Check can me lifted by also allowing trying PyObject_GetBuffer.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)