Message137143
| 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 |
|