[Python-Dev] Add sendfile() to core? (original) (raw)

Thomas Heller thomas.heller@ion-tof.com
Thu, 21 Mar 2002 08:45:18 +0100


From: "Andrew Kuchling" <akuchlin@mems-exchange.org>

The Medusa distribution contains a small module that wraps the sendfile() system call, available at least on Unix and FreeBSD. The man page explains what sendfile() does: [...] sendfile() is used when writing really high-performance Web servers, in order to save an unnecessary memory-to-memory copy. Question: should I make up a patch to add a sendfile() wrapper to Python?

There is a somewhat similar function on win32 (available in Win98/NT and newer versions, not in win95):

TransmitFile The Windows Sockets TransmitFile function transmits file data over a connected socket handle. This function uses the operating system's cache manager to retrieve the file data, and provides high-performance file data transfer over sockets. Note This function is a Microsoft-specific extension to the Windows Sockets specification. For more information, see Microsoft Extensions and Windows Sockets 2. BOOL TransmitFile( SOCKET hSocket, HANDLE hFile, DWORD nNumberOfBytesToWrite, DWORD nNumberOfBytesPerSend, LPOVERLAPPED lpOverlapped, LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, DWORD dwFlags );

Would make a nice addition IMO if sendfile is beeing exposed.

Thomas