How does python check memory footprint
This article mainly introduces how to check the memory footprint of python, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.
Check memory footprint
In Python, we can use the built-in module sys to check the memory consumed by each variable. As you can see from the following code, strings of different lengths consume different amounts of memory.
Import sysa, b, Love d = "I", "Love", "Python", 2020print (sys.getsizeof (a)) # 50print (sys.getsizeof (b)) # 53print (sys.getsizeof (c)) # 55print (sys.getsizeof (d)) # 28 Thank you for reading this article carefully. I hope the article "python how to check memory footprint" shared by the editor will be helpful to you. At the same time, I hope you will support me and pay attention to the industry information channel. More related knowledge is waiting for you to learn!