MCPcopy Index your code
hub / github.com/python/cpython / peek

Method peek

Lib/zipfile/__init__.py:1054–1065  ·  view source on GitHub ↗

Returns buffered bytes without advancing the position.

(self, n=1)

Source from the content-addressed store, hash-verified

1052 return io.BufferedIOBase.readline(self, limit)
1053
1054 def peek(self, n=1):
1055 """Returns buffered bytes without advancing the position."""
1056 if n > len(self._readbuffer) - self._offset:
1057 chunk = self.read(n)
1058 if len(chunk) > self._offset:
1059 self._readbuffer = chunk + self._readbuffer[self._offset:]
1060 self._offset = 0
1061 else:
1062 self._offset -= len(chunk)
1063
1064 # Return up to 512 bytes to reduce allocation overhead for tight loops.
1065 return self._readbuffer[self._offset: self._offset + 512]
1066
1067 def readable(self):
1068 if self.closed:

Callers

nothing calls this directly

Calls 1

readMethod · 0.95

Tested by

no test coverage detected