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

Method get_attr

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

Get an attribute by name. `attr_name` can be a `&str`, `String`, or `PyStrRef`.

(&self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

127 /// Get an attribute by name.
128 /// `attr_name` can be a `&str`, `String`, or `PyStrRef`.
129 pub fn get_attr<'a>(&self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine) -> PyResult {
130 let attr_name = attr_name.as_pystr(&vm.ctx);
131 self.get_attr_inner(attr_name, vm)
132 }
133
134 // get_attribute should be used for full attribute access (usually from user code).
135 #[cfg_attr(feature = "flame-it", flame("PyObjectRef"))]

Callers 3

get_aiterMethod · 0.45
has_attrMethod · 0.45
generic_getattr_optMethod · 0.45

Calls 2

as_pystrMethod · 0.80
get_attr_innerMethod · 0.80

Tested by

no test coverage detected