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

Method as_buffer

crates/stdlib/src/array.rs:1250–1263  ·  view source on GitHub ↗
(zelf: &Py<Self>, _vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1248
1249 impl AsBuffer for PyArray {
1250 fn as_buffer(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
1251 let array = zelf.read();
1252 let buf = PyBuffer::new(
1253 zelf.to_owned().into(),
1254 BufferDescriptor::format(
1255 array.len() * array.itemsize(),
1256 false,
1257 array.itemsize(),
1258 array.typecode_str().into(),
1259 ),
1260 &BUFFER_METHODS,
1261 );
1262 Ok(buf)
1263 }
1264 }
1265
1266 impl Representable for PyArray {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
formatFunction · 0.50
readMethod · 0.45
to_ownedMethod · 0.45
lenMethod · 0.45
itemsizeMethod · 0.45

Tested by

no test coverage detected