<jupyter_start><jupyter_text>source: https://stackoverflow.com/questions/40993626/list-memory-usage-in-ipython-and-jupyter<jupyter_code>import sys
import numpy as np
arr = np.random.random((10000,10000))
s = arr.shape
s
# These are the usual ipython objects, including this one you are creating
ipython_vars = ['In', 'Out', 'exit', 'quit', 'get_ipython', 'ipython_vars']

# Get a sorted list of the objects and their sizes in bytes
sorted([(x, sys.getsizeof(globals().get(x))) for x in dir() if not x.startswith('_') and x not in sys.modules and x not in ipython_vars], key=lambda x: x[1], reverse=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13744075829383887, 'fraction_numerical': 0.030015797788309637, 'mean_word_length': 5.967032967032967, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '650093', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 241, 'n_tokens_neox': 225, 'n_words': 66, 'path': 'notebooks/objects_size.ipynb', 'repo_name': 'miguelgfierro/pybase', 'size': '633'}