[Python-ideas] Atomic file.get(offset, length)

Antoine Pitrou solipsis at pitrou.net
Mon Jul 23 01:47:10 CEST 2012


On Sun, 22 Jul 2012 15:36:44 -0700
Guido van Rossum <guido at python.org> wrote:
> On Sun, Jul 22, 2012 at 2:25 PM, Victor Stinner
> <victor.stinner at gmail.com> wrote:
> >> "man pread" on OS/X suggests it exists there too
> >
> > "man pread" or "import os; help(os.pread" ;-) pread() and pwrite()
> > have been added to Python 3.3.
> 
> Awesome. :-) But does the io module offer an API that uses it? It's
> kind of awkward to have to call os.pread() with stream.fileno() as an
> argument.

It doesn't. I guess we could add an "offset" keyword-only argument to
read() and write(), but then we need to provide a Windows
implementation as well (it seems using overlapped I/O with
ReadFile() / WriteFile() could make it possible). Also, I'm not sure it
makes sense for buffered I/O, or only unbuffered.

Regards

Antoine.


-- 
Software development and contracting: http://pro.pitrou.net





More information about the Python-ideas mailing list