(py: Python, pyobject: &PyAny)
| 32 | } |
| 33 | |
| 34 | pub fn uget_slice<'a, T: Element>(py: Python, pyobject: &PyAny) -> PyResult<SliceGuard<'a, T>> { |
| 35 | let array: &PyArrayDyn<T> = pyobject.extract()?; |
| 36 | unsafe { |
| 37 | let slice = array |
| 38 | .as_slice() |
| 39 | .map_err(|_| pyo3::exceptions::PyTypeError::new_err("not contiguous"))?; |
| 40 | let slice = std::slice::from_raw_parts(slice.as_ptr(), slice.len()); |
| 41 | Ok(SliceGuard { |
| 42 | slice, |
| 43 | _ref: pyobject.into_py(py), |
| 44 | }) |
| 45 | } |
| 46 | } |