I think that Pympler has already beaten you to the punch on this one.
From their documentation:
>>> from pympler.asizeof import asizeof
>>> obj = [1, 2, (3, 4), 'text']
>>> asizeof(obj)
176
The source code can be found here.
More Related Contents:
- How unique is Python’s id()?
- Print the result obtained from an external window but without opening the window (the selected checkboxes are automatically saved in the database)
- Syntax error on print with Python 3 [duplicate]
- How to search and replace text in a file?
- How to access variables from different classes in tkinter?
- Converting int to bytes in Python 3
- multiprocessing: Understanding logic behind `chunksize`
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- How to use filter, map, and reduce in Python 3
- Does Python have a stack/heap and how is memory managed?
- Python Script returns unintended “None” after execution of a function [duplicate]
- How to run pip of different version of python using python command?
- Let JSON object accept bytes or let urlopen output strings
- builtins.TypeError: must be str, not bytes
- How to print a list with integers without the brackets, commas and no quotes? [duplicate]
- python tkinter return value from function used in command
- Safely evaluate simple string equation
- How to print like printf in Python3?
- Is there anything faster than dict()?
- Python print statement “Syntax Error: invalid syntax” [duplicate]
- How to convert a binary (string) into a float value?
- Set up Python simpleHTTPserver on Windows [duplicate]
- Pandas ParserError EOF character when reading multiple csv files to HDF5
- What does colon at assignment for list[:] = […] do in Python [duplicate]
- return value from one python script to another
- Building Python 3.7.1 – SSL module failed
- Limit Python VM memory
- Python 3 chokes on CP-1252/ANSI reading
- Using Sympy Equations for Plotting
- How to convert only numbers in a mixed list into float