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

Method dir

crates/vm/src/protocol/object.rs:60–76  ·  view source on GitHub ↗

PyObject *PyObject_Dir(PyObject *o)

(self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

58
59 // PyObject *PyObject_Dir(PyObject *o)
60 pub fn dir(self, vm: &VirtualMachine) -> PyResult<PyList> {
61 let attributes = self.class().get_attributes();
62
63 let dict = PyDict::from_attributes(attributes, vm)?.into_ref(&vm.ctx);
64
65 if let Some(object_dict) = self.dict() {
66 vm.call_method(
67 dict.as_object(),
68 identifier!(vm, update).as_str(),
69 (object_dict,),
70 )?;
71 }
72
73 let attributes: Vec<_> = dict.into_iter().map(|(k, _v)| k).collect();
74
75 Ok(PyList::from(attributes))
76 }
77}
78
79impl PyObject {

Callers

nothing calls this directly

Calls 10

get_attributesMethod · 0.80
collectMethod · 0.80
classMethod · 0.45
into_refMethod · 0.45
dictMethod · 0.45
call_methodMethod · 0.45
as_objectMethod · 0.45
as_strMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected