Make memoryview.__hash__() returns hash value of wrapped object

This commit is contained in:
lazylife7157
2019-10-05 01:41:49 +09:00
parent c8e6ca7271
commit c3af2bb858
2 changed files with 7 additions and 0 deletions

View File

@@ -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])