Try this:
sys.getsizeof(object)
getsizeof() Return the size of an object in bytes. It calls the object’s __sizeof__
method and adds an additional garbage collector overhead if the object is managed by the garbage collector.
More Related Contents:
- Fastest way to check if a value exists in a list
- Why does concatenation of DataFrames get exponentially slower?
- Which Python memory profiler is recommended? [closed]
- Why does Python code run faster in a function?
- A faster strptime?
- Roll rows of a matrix independently
- Efficient calculation of Fibonacci series
- Python string ‘join’ is faster (?) than ‘+’, but what’s wrong here?
- Simple Python Challenge: Fastest Bitwise XOR on Data Buffers
- Poor scaling of multiprocessing Pool.map() on a list of large objects: How to achieve better parallel scaling in python?
- Why is numpy.array so slow?
- Efficient evaluation of a function at every cell of a NumPy array
- Fast arbitrary distribution random sampling (inverse transform sampling)
- Mass string replace in python?
- Python: get a dict from a list based on something inside the dict
- Why is variable1 += variable2 much faster than variable1 = variable1 + variable2?
- why isn’t numpy.mean multithreaded?
- Why is Collections.counter so slow?
- Any way to speed up Python and Pygame?
- matplotlib savefig performance, saving multiple pngs within loop
- Is there a way to circumvent Python list.append() becoming progressively slower in a loop as the list grows?
- Speed up writing to files
- Efficiently replace elements in array based on dictionary – NumPy / Python
- What are the differences between bool() and operator.truth()?
- improving python code in Monte Carlo simulation
- differences between “d = dict()” and “d = {}”
- Is there any working memory profiler for Python3 [closed]
- Creating a numpy array of 3D coordinates from three 1D arrays
- Split Python sequence (time series/array) into subsequences with overlap
- numpy faster than numba and cython , how to improve numba code