Skip to content

Commit 83c3644

Browse files
committed
Replace vm._hash to obj.hash
1 parent 0d32e1a commit 83c3644

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

vm/src/protocol/object.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ impl PyObjectRef {
132132
}
133133

134134
pub fn hash(&self, vm: &VirtualMachine) -> PyResult<PyHash> {
135-
vm._hash(self)
135+
let hash = self
136+
.class()
137+
.mro_find_map(|cls| cls.slots.hash.load())
138+
.unwrap(); // hash always exist
139+
hash(self, vm)
136140
}
137141

138142
// const hash_not_implemented: fn(&PyObjectRef, &VirtualMachine) ->PyResult<PyHash> = crate::types::Unhashable::slot_hash;

vm/src/vm.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,14 +1885,6 @@ impl VirtualMachine {
18851885
self._cmp(&a, &b, op).map(|res| res.into_pyobject(self))
18861886
}
18871887

1888-
pub fn _hash(&self, obj: &PyObjectRef) -> PyResult<rustpython_common::hash::PyHash> {
1889-
let hash = obj
1890-
.class()
1891-
.mro_find_map(|cls| cls.slots.hash.load())
1892-
.unwrap(); // hash always exist
1893-
hash(obj, self)
1894-
}
1895-
18961888
pub fn obj_len_opt(&self, obj: &PyObjectRef) -> Option<PyResult<usize>> {
18971889
self.get_special_method(obj.clone(), "__len__")
18981890
.map(Result::ok)

0 commit comments

Comments
 (0)