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
I wrote a tool called RememberMe exactly for this. Basic usage:
from rememberme import memory a = [1, 2, 3] b = [a, a, a] print(memory(a)) # 172 bytes print(memory(b)) # 260 bytes. Duplication counted only once.
Hope it helps.