MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / get_ptr

Method get_ptr

src/buffer.rs:189–200  ·  view source on GitHub ↗

Gets a pointer to the specified item. If `indices.len() < self.dimensions()`, returns the start address of the sub-array at the specified dimension.

(&self, indices: &[usize])

Source from the content-addressed store, hash-verified

187 ///
188 /// If `indices.len() < self.dimensions()`, returns the start address of the sub-array at the specified dimension.
189 pub fn get_ptr(&self, indices: &[usize]) -> *mut libc::c_void {
190 let shape = &self.shape()[..indices.len()];
191 for i in 0..indices.len() {
192 assert!(indices[i] < shape[i]);
193 }
194 unsafe {
195 ffi::PyBuffer_GetPointer(
196 &*self.0 as *const ffi::Py_buffer as *mut ffi::Py_buffer,
197 indices.as_ptr() as *mut usize as *mut crate::Py_ssize_t,
198 )
199 }
200 }
201
202 /// Gets whether the underlying buffer is read-only.
203 #[inline]

Callers

nothing calls this directly

Calls 3

shapeMethod · 0.80
lenMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected