[Python-Dev] Add sendfile() to core?
Guido van Rossum
guido at python.org
Sun Jan 9 20:17:40 CET 2011
Isn't that just shutil.copyfileobj()?
On Fri, Jan 7, 2011 at 11:55 PM, max ulidtko <ulidtko at gmail.com> wrote:
> On Wed, 20 Mar 2002 14:53:58 -0500, Andrew Kuchling wrote:
> | 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?
> So, was this proposal rejected? If so, for what reasons?
> Wrapper of such a useful call would be of great convenience, especially
> considering its availability on Win32 (see Thomas Heller's notice, ).
> Anyway, when one needs to send (arbitrarily large) files to a socket and
> back, ugly and slow workarounds are born, like this one:
> def copy_file(file1, file2, length, blocksize=40960):
> """ Transfer exactly length bytes from one file-like object to
> another """
> sofar = 0
> while sofar < length:
> amount = blocksize if sofar + blocksize <= length \
> else length - sofar
> sofar += amount
> Using hypothetical os.sendfile() would be so much better!
> The only difficulty I can see is the choice of name for the wrapper.
> IMO, using "sendfile" from Linux and FreeBSD is pretty much okay; but
> objections may arise.
>  http://mail.python.org/pipermail/python-dev/2002-March/021543.html
> max ulidtko
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev