Skip to content

Commit b4b1e26

Browse files
authored
Merge pull request RustPython#3714 from youknowone/cut_attr
cut get_attr not to inline its bloated body but allow optionally
2 parents bf7d376 + 9763d8b commit b4b1e26

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

vm/src/protocol/object.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,15 @@ impl PyObject {
8080
self.get_attr(attr_name, vm).map(|o| vm.is_none(&o))
8181
}
8282

83-
// get_attribute should be used for full attribute access (usually from user code).
84-
#[cfg_attr(feature = "flame-it", flame("PyObjectRef"))]
8583
pub fn get_attr(&self, attr_name: impl IntoPyStrRef, vm: &VirtualMachine) -> PyResult {
8684
let attr_name = attr_name.into_pystr_ref(vm);
85+
self._get_attr(attr_name, vm)
86+
}
87+
88+
// get_attribute should be used for full attribute access (usually from user code).
89+
#[cfg_attr(feature = "flame-it", flame("PyObjectRef"))]
90+
#[inline]
91+
fn _get_attr(&self, attr_name: PyStrRef, vm: &VirtualMachine) -> PyResult {
8792
vm_trace!("object.__getattribute__: {:?} {:?}", obj, attr_name);
8893
let getattro = self
8994
.class()
@@ -290,6 +295,7 @@ impl PyObject {
290295
_ => Err(vm.new_unsupported_binop_error(self, other, op.operator_token())),
291296
}
292297
}
298+
#[inline(always)]
293299
pub fn rich_compare_bool(
294300
&self,
295301
other: &Self,

0 commit comments

Comments
 (0)