Question #307

When the length is bigger than 3, which one is more compact?

See the code below:

from sys import getsizeof
n = 10
d = dict(enumerate(range(n)))
print(getsizeof(d))
lot = list(d.items())
print(getsizeof(lot) + sum(map(getsizeof, lot)))
>>368
>>840

(twitter.com/raymondh/status/1234864681421918208)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵