Skip to content

Instantly share code, notes, and snippets.

@karolzak
Created August 21, 2019 16:27
Show Gist options
  • Save karolzak/c412a39a7c2818cb8317c477463ea64a to your computer and use it in GitHub Desktop.
Save karolzak/c412a39a7c2818cb8317c477463ea64a to your computer and use it in GitHub Desktop.
Get info about objects in memory
import sys
# 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
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment