mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Replace vm._hash to obj.hash
This commit is contained in:
@@ -132,7 +132,11 @@ impl PyObjectRef {
|
||||
}
|
||||
|
||||
pub fn hash(&self, vm: &VirtualMachine) -> PyResult<PyHash> {
|
||||
vm._hash(self)
|
||||
let hash = self
|
||||
.class()
|
||||
.mro_find_map(|cls| cls.slots.hash.load())
|
||||
.unwrap(); // hash always exist
|
||||
hash(self, vm)
|
||||
}
|
||||
|
||||
// const hash_not_implemented: fn(&PyObjectRef, &VirtualMachine) ->PyResult<PyHash> = crate::types::Unhashable::slot_hash;
|
||||
|
||||
@@ -1885,14 +1885,6 @@ impl VirtualMachine {
|
||||
self._cmp(&a, &b, op).map(|res| res.into_pyobject(self))
|
||||
}
|
||||
|
||||
pub fn _hash(&self, obj: &PyObjectRef) -> PyResult<rustpython_common::hash::PyHash> {
|
||||
let hash = obj
|
||||
.class()
|
||||
.mro_find_map(|cls| cls.slots.hash.load())
|
||||
.unwrap(); // hash always exist
|
||||
hash(obj, self)
|
||||
}
|
||||
|
||||
pub fn obj_len_opt(&self, obj: &PyObjectRef) -> Option<PyResult<usize>> {
|
||||
self.get_special_method(obj.clone(), "__len__")
|
||||
.map(Result::ok)
|
||||
|
||||
Reference in New Issue
Block a user