We could fill the buffer while moving its start point to 0. Furthermore, "We never return more than self.buffer_size." The Please note : "a desired /minimal/ number of bytes" (minimal, not The argument indicates a desired minimal number of bytes weĭo at most one raw read to satisfy it. """Returns buffered bytes without advancing the position. never/ returns more than the buffer size.Īs for the fact that peek() doesn't behave as documented, I disagree. Size and remain compatible with non-seekable raw streams. Lucas, it is indeed impossible for peek() to return more than the buffer There isn't a case where the peek function would work properly (exceptĬouldn't we use a read() followed by a seek() instead? Peek is too big ( > buffer_len - start ) the cursor will move, thus I didn't do many tests but I guess it is ok (it works like I think it I think the argument should be used as a upper bound I will look at Since it just returns the current buffered data from peek, no matterĪuthor: Benjamin Peterson (benjamin.peterson) * However, the old description was also wrong for the io-c implementation The previous documentation that Alexandre quotes in the April wasĬhanged to the current description in late April without anyĬorresponding change to the implementation: Peek() so that the argument actually was a cap. Initial response to that thread was to support the idea of changing In which case it is the documentation that needs to be fixed, as it isĬurrently not just misleading but flat out wrong. The thread from April suggests the current behaviour may be intentional, Have = len(self._read_buf) - self._read_pos Thereas the parameter n is the _max_ length of returned bytes. Return 1 (or n if specified) bytes from a buffer without advancing the The documented behavior of io.BufferedReader.peek() states: Io.BufferedReader.peek(): Documentation differs from Implementationīenjamin.peterson, conf, desbma, martin.panter, ncoghlan, pitrou, trottĬreated on 06:15 by trott, last changed 14:56 by admin.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |