This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jcon
Recipients benjamin.peterson, jcon, nadeem.vawda, pitrou, stutzbach, vstinner
Date 2011-05-28.19:17:12
SpamBayes Score 2.9535494e-07
Marked as misclassified No
Message-id <1306610234.1.0.791958193778.issue12053@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2011-05-28 19:17:14jconsetrecipients: + jcon, pitrou, vstinner, nadeem.vawda, benjamin.peterson, stutzbach
2011-05-28 19:17:14jconsetmessageid: <1306610234.1.0.791958193778.issue12053@psf.upfronthosting.co.za>
2011-05-28 19:17:13jconlinkissue12053 messages
2011-05-28 19:17:13jconcreate