1 parent e4bded8 commit b3f25ffCopy full SHA for b3f25ff
1 file changed
vm/src/obj/objbytes.rs
@@ -1,4 +1,5 @@
1
use std::cell::Cell;
2
+use std::mem::size_of;
3
use std::ops::Deref;
4
5
use wtf8;
@@ -149,6 +150,11 @@ impl PyBytesRef {
149
150
}
151
152
153
+ #[pymethod(name = "__sizeof__")]
154
+ fn sizeof(self, _vm: &VirtualMachine) -> PyResult<usize> {
155
+ Ok(size_of::<Self>() + self.inner.elements.len() * size_of::<u8>())
156
+ }
157
+
158
#[pymethod(name = "__add__")]
159
fn add(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
160
if let Ok(other) = PyByteInner::try_from_object(vm, other) {
0 commit comments