forked from Rust-related/RustPython
Implemented bytes.__sizeof__
This commit is contained in:
@@ -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<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) {
|
||||
|
||||
Reference in New Issue
Block a user