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

Method peek

Lib/_pyio.py:1130–1139  ·  view source on GitHub ↗

Returns buffered bytes without advancing the position. The argument indicates a desired minimal number of bytes; we do at most one raw read to satisfy it. We never return more than self.buffer_size.

(self, size=0)

Source from the content-addressed store, hash-verified

1128 return out[:n] if out else nodata_val
1129
1130 def peek(self, size=0):
1131 """Returns buffered bytes without advancing the position.
1132
1133 The argument indicates a desired minimal number of bytes; we
1134 do at most one raw read to satisfy it. We never return more
1135 than self.buffer_size.
1136 """
1137 self._checkClosed("peek of closed file")
1138 with self._read_lock:
1139 return self._peek_unlocked(size)
1140
1141 def _peek_unlocked(self, n=0):
1142 want = min(n, self.buffer_size)

Callers 3

nreadaheadMethod · 0.45
peekMethod · 0.45
peekMethod · 0.45

Calls 2

_peek_unlockedMethod · 0.95
_checkClosedMethod · 0.45

Tested by

no test coverage detected