Message135731
| Author |
jcon |
| Recipients |
benjamin.peterson, jcon, pitrou, stutzbach, vstinner |
| Date |
2011年05月10日.19:37:24 |
| SpamBayes Score |
3.941054e-09 |
| Marked as misclassified |
No |
| Message-id |
<1305056245.15.0.0737815347229.issue12053@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
A prefetch() method for Buffered IO may greatly assist 3rd party buffering among other gains. If nothing else, it is worth experimenting with.
Discussion on the topic is here: http://mail.python.org/pipermail/python-ideas/2010-September/008180.html
A summary of the method proposed (by Antoine Pitrou):
prefetch(self, buffer, skip, minread)
Skip `skip` bytes from the stream. Then, try to read at
least `minread` bytes and write them into `buffer`. The file
pointer is advanced by at most `skip + minread`, or less if
the end of file was reached. The total number of bytes written
in `buffer` is returned, which can be more than `minread`
if additional bytes could be prefetched (but, of course,
cannot be more than `len(buffer)`).
Arguments:
- `buffer`: a writable buffer (e.g. bytearray)
- `skip`: number of bytes to skip (must be >= 0)
- `minread`: number of bytes to read (must be >= 0 and <= len(buffer)) |
|