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

Method from_object

crates/vm/src/builtins/memory.rs:76–83  ·  view source on GitHub ↗

this should be the main entrance to create the memoryview to avoid the chained memoryview

(obj: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

new_viewMethod · 0.80

Tested by

no test coverage detected