Windows provides a number of techniques for high-performance file
I/O. The most common is overlapped I/O. Using overlapped I/O, the
win32file.WriteFile() operations are asynchronous
and return before the actual I/O operation has completed. When the
I/O operation finally completes, a Windows event is signaled.
Overlapped I/O does have some requirements normal I/O operations don’t:
The operating system doesn’t automatically advance the file
pointer. When not using overlapped I/O, a
WriteFile operation automatically advances the
file pointer, so the next operation automatically reads the
subsequent data in the file. When using overlapped I/O, you must
manage the location in the file manually.
The standard technique of returning a Python string object from
win32file.ReadFile() doesn’t work. Because
the I/O operation has not completed when the call returns, a Python
string can’t be used.
As you can imagine, the code for performing overlapped I/O is more complex than when performing synchronous I/O. Chapter 18, contains some sample code that uses basic overlapped I/O on a Windows-named pipe.