diff --git a/vm/src/obj/objbytes.rs b/vm/src/obj/objbytes.rs index 190fdd061d..db561e4355 100644 --- a/vm/src/obj/objbytes.rs +++ b/vm/src/obj/objbytes.rs @@ -1,4 +1,5 @@ use std::cell::Cell; +use std::mem::size_of; use std::ops::Deref; use wtf8; @@ -149,6 +150,11 @@ impl PyBytesRef { } } + #[pymethod(name = "__sizeof__")] + fn sizeof(self, _vm: &VirtualMachine) -> PyResult { + Ok(size_of::() + self.inner.elements.len() * size_of::()) + } + #[pymethod(name = "__add__")] fn add(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { if let Ok(other) = PyByteInner::try_from_object(vm, other) {