MCPcopy Index your code
hub / github.com/RustPython/RustPython / read1

Method read1

Lib/_pyio.py:1133–1145  ·  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

1131 return self._read_buf[self._read_pos:]
1132
1133 def read1(self, size=-1):
1134 """Reads up to size bytes, with at most one read() system call."""
1135 # Returns up to size bytes. If at least one byte is buffered, we
1136 # only return buffered bytes. Otherwise, we do one raw read.
1137 self._checkClosed("read of closed file")
1138 if size < 0:
1139 size = self.buffer_size
1140 if size == 0:
1141 return b""
1142 with self._read_lock:
1143 self._peek_unlocked(1)
1144 return self._read_unlocked(
1145 min(size, len(self._read_buf) - self._read_pos))
1146
1147 # Implementing readinto() and readinto1() is not strictly necessary (we
1148 # could rely on the base class that provides an implementation in terms of

Callers

nothing calls this directly

Calls 5

_peek_unlockedMethod · 0.95
_read_unlockedMethod · 0.95
minFunction · 0.85
lenFunction · 0.85
_checkClosedMethod · 0.45

Tested by

no test coverage detected