John O'Connor <tehj...@gmail.com> added the comment: I started a draft in python. I am attaching the _pyio version along with tests. I will continue work on the C implementation and eventually documentation if this is well received. It seems straightforward, I am interested to see what you guys think.
Also, there are now 2 places which use hasattr(self, "peek"). I was wondering if it would make sense to add peek() to BufferedIOBase and raise UnsupportedOperation or return b"". Some benchmarks.. $ ./python -m timeit -s "from _pyio import open;f = open('LICENSE', 'rb'); b=bytearray(128)" 'while f.prefetch(b, 4, 4): pass' _pyio.BufferedIOBase.prefetch: 100000 loops, best of 3: 10.6 usec per loop _pyio.BufferedReader.prefetch: 100000 loops, best of 3: 6 usec per loop $ ./python -m timeit -s "from _pyio import open;f = open('LICENSE', 'rb');b=bytearray(4);" 'while f.read(4): f.readinto(b)' 100000 loops, best of 3: 5.07 usec per loop ---------- keywords: +patch Added file: http://bugs.python.org/file22168/issue12053-pyio.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12053> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com