[Python-ideas] speeding up shutil.copy*()
Christian Heimes
christian at python.org
Sun Mar 3 19:03:55 CET 2013
Am 03.03.2013 18:02, schrieb Charles-François Natali:
> I've also written a dirty patch to use sendfile(). Here, the
> improvement is really significant:
>
> With sendfile():
> $ ./python -m timeit -s "import shutil" "shutil.copyfile('/tmp/foo',
> '/dev/null')"
> 100 loops, best of 3: 5.39 msec per loop
>
> Thoughts?
sendfile() is a Linux-only syscall. It's also limited to certain kinds
of file descriptors. The limitations have been lifted in recent kernel
versions.
http://linux.die.net/man/2/sendfile
TL;DR the input fd must support mmap. The output fd used to be socket fd
only, since 2.6.33 sendfile() supports any fd as output fd.
More information about the Python-ideas
mailing list