MCPcopy Index your code
hub / github.com/RustPython/RustPython / getsizeof

Function getsizeof

crates/vm/src/stdlib/sys.rs:965–974  ·  view source on GitHub ↗
(args: GetsizeofArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

963
964 #[pyfunction]
965 fn getsizeof(args: GetsizeofArgs, vm: &VirtualMachine) -> PyResult {
966 let sizeof = || -> PyResult<usize> {
967 let res = vm.call_special_method(&args.obj, identifier!(vm, __sizeof__), ())?;
968 let res = res.try_index(vm)?.try_to_primitive::<usize>(vm)?;
969 Ok(res + core::mem::size_of::<PyObject>())
970 };
971 sizeof()
972 .map(|x| vm.ctx.new_int(x).into())
973 .or_else(|err| args.default.ok_or(err))
974 }
975
976 #[pyfunction]
977 fn getfilesystemencoding(vm: &VirtualMachine) -> PyStrRef {

Callers

nothing calls this directly

Calls 5

sizeofFunction · 0.85
call_special_methodMethod · 0.80
try_indexMethod · 0.80
mapMethod · 0.45
new_intMethod · 0.45

Tested by

no test coverage detected