Martin Panter <vadmium...@gmail.com> added the comment: Looks like you want to use a "readinto" method to reduce data copying.
One problem is that it is not specified exactly what kind of object "copyfileobj" supports reading from. The documentation only says "file-like". According to the glossary, this means io.RawIOBase, BufferedIOBase, or TextIOBase. However TextIOBase doesn't have a "readinto" method. And it wouldn't be hard to find that someone has written their own class that doesn't have "readinto" either. The other problem is you still need to support a negative "length" value, which is easier to do by calling "read". ---------- nosy: +martin.panter title: improved shutil.py function -> Call readinto in shutil.copyfileobj _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32529> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com