Implemented bytes.__sizeof__
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<usize> {
+ Ok(size_of::<Self>() + self.inner.elements.len() * size_of::<u8>())
+ }
+
#[pymethod(name = "__add__")]
fn add(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
if let Ok(other) = PyByteInner::try_from_object(vm, other) {
