Sometimes, we want to profile memory usage in Python.
In this article, we’ll look at how to profile memory usage in Python.
How to profile memory usage in Python?
To profile memory usage in Python, we can use the guppy
module.
To install it, we run
pip install guppy3
Then we use it by writing
from guppy import hpy
h = hpy()
print(h.heap())
to call heap
to return a string with the list of items using memory.
All memory sizes are in bytes.
Conclusion
To profile memory usage in Python, we can use the guppy
module.