Repository navigation
gh-90533: Implement BytesIO.peek() #150917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 47 commits
b833b83
50a2cfb
eaa7672
00457ae
882579d
c1eed72
afc200c
79ab9a4
b493914
2a1c85c
d398717
26d1e81
9a19ff9
9300ade
d214089
d6691b8
3e51adb
3661b65
cd40d77
04372bd
6b9ae8c
f7406f6
d9528e2
bc8134b
b6ffca8
5fe5645
4126a64
1ea40c2
77e04d6
4d2f2dd
c16bebf
08bd7da
6174fca
b8b8cf4
7ac914e
abbd8f0
07d9e4d
3d57f45
023ad25
203749b
32fd791
7ef7f6d
e038ae2
3b71960
9c6e8ad
0be970e
e2d3929
5f07faa
bb5f648
8a96f88
5105c55
11e65fe
514d102
bead21a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -771,6 +771,15 @@ than raw I/O does. | |
|
|
||
| Return :class:`bytes` containing the entire contents of the buffer. | ||
|
|
||
| .. method:: peek(size=0, /) | ||
|
|
||
| Return a copy of the buffer from the current position onwards without advancing the position. | ||
|
|
||
| If *size* is zero or omitted, the returned :class:`bytes` object extends to EOF. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least, the Python implementation limits the returned string to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed the limit even in the Python implementation.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would still be good to default limit. That way if there's a 1GB BytesIO and you
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I misremembered what was said earlier. I will fix it next week. Should maybe the the signature be changed to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still prefer 0 as a default, differentiating between "unspecified" and "exactly this size". |
||
| Otherwise, at most *size* bytes are returned. | ||
| Return an empty :class:`bytes` object at EOF. | ||
|
|
||
| .. versionadded:: next | ||
|
|
||
| .. method:: read1(size=-1, /) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add :meth:`io.BytesIO.peek`. | ||
|
vstinner marked this conversation as resolved.
Resolved
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.