mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
Make memoryview.__hash__() returns hash value of wrapped object
This commit is contained in:
1 parent
c8e6ca7271
commit
c3af2bb858
2 files changed
+7
No files matched your search
@@ -4,3 +4,5 @@ a = memoryview(obj)
|
||||
assert a.obj == obj
|
||||
|
||||
assert a[2:3] == b"c"
|
||||
|
||||
assert hash(obj) == hash(a)
|
||||
@@ -34,6 +34,11 @@ impl PyMemoryView {
|
||||
self.obj_ref.clone()
|
||||
}
|
||||
|
||||
#[pymethod(name = "__hash__")]
|
||||
fn hash(&self, vm: &VirtualMachine) -> PyResult {
|
||||
vm.call_method(&self.obj_ref, "__hash__", vec![])
|
||||
}
|
||||
|
||||
#[pymethod(name = "__getitem__")]
|
||||
fn getitem(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
|
||||
vm.call_method(&self.obj_ref, "__getitem__", vec![needle])
|
||||
|
||||
Reference in new issue
Block a user