python / cpython

The Python programming language
https://www.python.org
Other
63.51k stars 30.42k forks source link

Implement os.readv() / os.writev() in Windows port #71533

Open 01e27b45-90f2-4c74-9e5e-7e7e54c3d78e opened 8 years ago

01e27b45-90f2-4c74-9e5e-7e7e54c3d78e commented 8 years ago
BPO 27346
Nosy @pfmoore, @tjguk, @socketpair, @zware, @eryksun, @zooba

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['3.8', '3.9', 'expert-IO', 'type-feature', 'library', '3.10', 'OS-windows'] title = 'Implement os.readv() / os.writev() in Windows port' updated_at = user = 'https://github.com/socketpair' ``` bugs.python.org fields: ```python activity = actor = 'eryksun' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)', 'Windows', 'IO'] creation = creator = 'socketpair' dependencies = [] files = [] hgrepos = [] issue_num = 27346 keywords = [] message_count = 6.0 messages = ['268782', '268785', '268788', '268799', '388781', '388797'] nosy_count = 6.0 nosy_names = ['paul.moore', 'tim.golden', 'socketpair', 'zach.ware', 'eryksun', 'steve.dower'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'pending' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue27346' versions = ['Python 3.8', 'Python 3.9', 'Python 3.10'] ```

01e27b45-90f2-4c74-9e5e-7e7e54c3d78e commented 8 years ago

These functions are not implemented natively in Windows, but the Windows API has analogous functions ReadFileScatter and WriteFileGather.

01e27b45-90f2-4c74-9e5e-7e7e54c3d78e commented 8 years ago

Also do not forget to fix documentation: bpo-27021

01e27b45-90f2-4c74-9e5e-7e7e54c3d78e commented 8 years ago

however, unlike the POSIX functions, they require the alignment of each buffer on a memory page

eryksun commented 8 years ago

ReadFileScatter and WriteFileGather also require a handle for a file that's opened with FILE_FLAG_OVERLAPPED (asynchronous access; the file pointer is not updated) and FILE_FLAG_NO_BUFFERING (buffers must be a multiple of the physical sector size and aligned to the physical sector size). So Python wouldn't be able to use the C runtime's POSIX (low) I/O implementation. ISTM this requires resolving bpo-12939, with support for overlapped I/O.

eryksun commented 3 years ago

The need for asynchronous I/O (i.e. FILE_FLAG_OVERLAPPED) with ReadFileScatter() and WriteFileGather() makes them a poor fit for POSIX os.readv() and os.writev(), since we can't open the file with open() or os.open(). Python's socket module opens sockets in asynchronous mode, but ReadFileScatter() and WriteFileGather() don't support sockets, and there are socket-specific alternatives (e.g. WSASend with multiple buffers). If these Windows API functions are supported at all, I expect it will be in _winapi or _overlapped, and only if needed by the standard library.

I'm changing the status of this enhancement request to pending, awaiting feedback from Марк and the core developers.

01e27b45-90f2-4c74-9e5e-7e7e54c3d78e commented 3 years ago

I'm not interested in Windows platform anymore.