On Sun, 9 Jan 2011 11:17:40 -0800, Guido van Rossum wrote: | Isn't that just shutil.copyfileobj()? |
This function has two drawbacks. First, it copies until EOF, and has no possibility to copy exactly N bytes from source fd (say, opened socket). This is the reason why I (re)wrote my custom copying function - to allow that. The second drawback is not using huge performance bonus achievable with sendfile(2) syscall on some unices and TransmitFile() on win32. It allows for sending and receiving files at ethernet speeds with no CPU load at all, because no memory copying occurs (and no Python wrapper objects would be created for the buffers, no heap allocation, etc). All needed I/O requests are handled inside the kernel without a single copying of data. Thus for e.g. FTP servers using this syscall became a standard. It would be good if Python supported it. P.S. There seems to be a package which enables the sendfile support for Linux, FreeBSD and AIX, <http://pypi.python.org/pypi/py-sendfile/>. Though it's available only for 2.x. Hopefully I'll end up with a patch soon. ------- Regards, 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/archive%40mail-archive.com