📜  如何在python代码示例中获取对象的大小

📅  最后修改于: 2022-03-11 14:45:18.618000             🧑  作者: Mango

代码示例1
import sys
object = set()

print(sys.getsizeof(object))
##### will get 216 possibly based on version 3.9 ###

###  use different objects like list(), dict(), str(), int(), float(), etc..###
### for getting to know size of each objects and use the most appropriate ###
## particularly set and dict will seem to not change in size even after ##
## adding lots of values but they are just so huge, only use them to store ##
## large values ##