I was surprised that sys.getsizeof( 10000*[x] ) is 40036 regardless of x: 0, \"a\", 1000*\"a\", {}. Is there a deep_getsizeof which properly co
sys.getsizeof( 10000*[x] )
deep_getsizeof
mylist = 10000 * [x] means create a list of size 10000 with 10000 references to object x.
mylist = 10000 * [x]
Object x is not copied - only a single one exists in memory!!!
x
So to use getsizeof, it would be: sys.getsizeof(mylist) + sys.getsizeof(x)
sys.getsizeof(mylist) + sys.getsizeof(x)