[Python-Dev] io.BufferedReader.peek() Behaviour in python3.1

Antoine Pitrou solipsis at pitrou.net
Sat Jun 13 14:33:46 CEST 2009


Frederick Reeve <cylix <at> solace.info> writes:
> 
> peek(n):
> If n is less than 0, None, or not set; return buffer contents with out
> advancing stream position. If the buffer is empty read a full chunk and
> return the buffer.  Otherwise return exactly n bytes up to _chunk
> size_(not contents) with out advancing the stream position.  If the
> buffer contents is less than n, buffer an additional chunk from the
> "raw" stream before hand.  If EOF is encountered during any raw read
> then return as much as we can up to n. (maybe I should write that in
> code form??)

This proposal looks reasonable to me. Please note that it's too late for 3.1
anyway - we're in release candidate phase. Once you have a patch, you can post
it on the bug tracker.

Regards

Antoine.




More information about the Python-Dev mailing list