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

Method read1

Lib/_pyio.py:1152–1164  ·  view source on GitHub ↗

Reads up to size bytes, with at most one read() system call.

(self, size=-1)

Source from the content-addressed store, hash-verified

1150 return self._read_buf[self._read_pos:]
1151
1152 def read1(self, size=-1):
1153 """Reads up to size bytes, with at most one read() system call."""
1154 # Returns up to size bytes. If at least one byte is buffered, we
1155 # only return buffered bytes. Otherwise, we do one raw read.
1156 self._checkClosed("read of closed file")
1157 if size < 0:
1158 size = self.buffer_size
1159 if size == 0:
1160 return b""
1161 with self._read_lock:
1162 self._peek_unlocked(1)
1163 return self._read_unlocked(
1164 min(size, len(self._read_buf) - self._read_pos))
1165
1166 # Implementing readinto() and readinto1() is not strictly necessary (we
1167 # could rely on the base class that provides an implementation in terms of

Callers

nothing calls this directly

Calls 3

_peek_unlockedMethod · 0.95
_read_unlockedMethod · 0.95
_checkClosedMethod · 0.45

Tested by

no test coverage detected