Isn't that just shutil.copyfileobj()?

On Fri, Jan 7, 2011 at 11:55 PM, max ulidtko <ulid...@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, [1]).
>
> 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
>        file2.write(file1.read(amount))
>        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.
>
> [1] http://mail.python.org/pipermail/python-dev/2002-March/021543.html
>
> ------
> Sincerely,
> max ulidtko
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to