gh-90533: Implement BytesIO.peek()#150917
Conversation
This allows peek() to use the same optimization that read_bytes() has of returning a reference to the buffer when possible (without copying).
Semantic change: The default argument for peek is now size=1.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Documentation build overview
18 files changed ·
|
Co-authored-by: Stan Ulbrych <stan@python.org>
|
Looks like |
|
The "Windows (free threading)" failure looks like a flaky on |
I created issue gh-150960 to track the test_logging failure. |
|
CI all green! :) |
| .. method:: peek(size=0, /) | ||
|
|
||
| Return bytes from the current position onwards without advancing the position. | ||
| At least one byte of data is returned if not at EOF. |
There was a problem hiding this comment.
The size=0 case is not well documented. It's unclear to me when I read the doc if peek() or peek(0) return an empty string or something else.
Closes #90533
Replaces #30808