MCPcopy Create free account
hub / github.com/ml-explore/mlx / _read

Method _read

python/src/load.cpp:164–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162
163 private:
164 void _read(char* data, size_t n) {
165 nb::object memview =
166 nb::steal<nb::object>(PyMemoryView_FromMemory(data, n, PyBUF_WRITE));
167 if (!memview.is_valid()) {
168 throw std::runtime_error("[load] Failed to create memoryview for read");
169 }
170 nb::object bytes_read = readinto_func_(memview);
171
172 if (bytes_read.is_none() || nb::cast<size_t>(bytes_read) < n) {
173 throw std::runtime_error("[load] Failed to read from python stream");
174 }
175 }
176
177 nb::object pyistream_;
178 nb::object readinto_func_;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected