Issue 9962: GzipFile doesn't have peek() (original) (raw)

Created on 2010-09-27 21:38 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
gzippeek.patch pitrou,2010-09-27 23:56
gzippeek2.patch pitrou,2010-09-28 21:35 review
gzipfixup.patch pitrou,2010-09-30 22:37
Messages (12)
msg117476 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-27 21:38
GzipFile claims to implement BufferedIOBase but doesn't have peek().
msg117491 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-27 23:56
Here is a first patch, tests still need to be written.
msg117552 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-28 21:35
Same patch with tests.
msg117594 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-29 10:50
Committed in r85100.
msg117706 - (view) Author: Nir Aides (nirai) (Python triager) Date: 2010-09-30 08:03
Hi Antoine, BufferedIOBase is not documented to have peek(): http://docs.python.org/dev/py3k/library/io.html Small note about patch: 1) IOError string says "read() on write-only...", should be "peek() on write-only..." ? 2) Should be min() in self._read(max(self.max_read_chunk, n))
msg117752 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-30 17:01
Hir Nir, > BufferedIOBase is not documented to have peek(): > http://docs.python.org/dev/py3k/library/io.html Ah, you're right. > Small note about patch: > 1) IOError string says "read() on write-only...", should be "peek() on write-only..." ? Indeed. > 2) Should be min() in self._read(max(self.max_read_chunk, n)) Actually, I think I should have reproduced the algorithm in read(), where there's a read_size distinct from the size requested by the user. Thanks for the review, it looks like I should have waited a bit before committing :)
msg117766 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-30 22:37
Here is a patch fixing these issues.
msg117782 - (view) Author: Nir Aides (nirai) (Python triager) Date: 2010-10-01 10:01
Should be min(n, 1024) instead of max(...)
msg117785 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-01 11:15
> Should be min(n, 1024) instead of max(...) Well, no, because we want to buffer a non-trivial amount of bytes for the next accesses. So, if n < 1024, buffer at least 1024 bytes.
msg117786 - (view) Author: Nir Aides (nirai) (Python triager) Date: 2010-10-01 11:39
Right, I missed the change from self.max_read_chunk to 1024 (read_size). Should not peek() limit to self.max_read_chunk as read() does?
msg117788 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-01 11:58
> Right, I missed the change from self.max_read_chunk to 1024 > (read_size). Should not peek() limit to self.max_read_chunk as read() > does? This is used for the chunking of huge reads, but for peek(): 1) there is no chunking (peek() should do at most one raw read) 2) huge reads are not really the use case peek() is intended for
msg117986 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-04 21:55
I've committed the improvements in r85221. Thank you!
History
Date User Action Args
2022-04-11 14:57:06 admin set github: 54171
2010-10-04 21:55:55 pitrou set status: open -> closedmessages: +
2010-10-01 11:58:00 pitrou set messages: +
2010-10-01 11:39:24 nirai set messages: +
2010-10-01 11:15:58 pitrou set messages: +
2010-10-01 10:01:54 nirai set messages: +
2010-09-30 22:37:01 pitrou set files: + gzipfixup.patchmessages: +
2010-09-30 22:26:03 pitrou set status: closed -> open
2010-09-30 17:01:14 pitrou set messages: +
2010-09-30 08:03:05 nirai set messages: +
2010-09-29 10:50:07 pitrou set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2010-09-28 22:04:01 pitrou set stage: needs patch -> patch review
2010-09-28 21:35:10 pitrou set files: + gzippeek2.patchmessages: +
2010-09-27 23:56:49 pitrou set files: + gzippeek.patchkeywords: + patchmessages: +
2010-09-27 21:38:34 pitrou create