this should be the main entrance to create the memoryview to avoid the chained memoryview
(obj: &PyObject, vm: &VirtualMachine)
| 74 | /// this should be the main entrance to create the memoryview |
| 75 | /// to avoid the chained memoryview |
| 76 | pub fn from_object(obj: &PyObject, vm: &VirtualMachine) -> PyResult<Self> { |
| 77 | if let Some(other) = obj.downcast_ref::<Self>() { |
| 78 | Ok(other.new_view()) |
| 79 | } else { |
| 80 | let buffer = PyBuffer::try_from_borrowed_object(vm, obj)?; |
| 81 | Self::from_buffer(buffer, vm) |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | /// don't use this function to create the memoryview if the buffer is exporting |
| 86 | /// via another memoryview, use PyMemoryView::new_view() or PyMemoryView::from_object |