14.2.12. crate_anon.common.memsize

crate_anon/common/memsize.py


Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

This file is part of CRATE.

CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.


Calculate the size of objects in memory (fast).

From https://stackoverflow.com/questions/449560/how-do-i-determine-the-size-of-an-object-in-python

crate_anon.common.memsize.getsize(obj: Any, assume_none_denied: bool = False) int[source]

Return the total size (in bytes) of the object and its members. From https://stackoverflow.com/questions/449560/how-do-i-determine-the-size-of-an-object-in-python

Parameters:
  • obj – Object to check.

  • assume_none_denied – Skip checks for classes/modules/functions. Assume that all objects should be checked (typically, meaning that the caller guarantees not to pass stuff that doesn’t need checking).