このコード スニペットが 2 つの異なる関数でバイト単位のサイズが異なる理由。私は32ビット版のpython 2.7.3を使用しています
1) 辞書付き:-
from sys import getsizeof
l = range(20)
d = {k:v for k,v in enumerate(l)} #creating a dict
d.__sizeof__() #gives size in bytes
508 #size of dictionary 'd' in bytes
getsizeof(d)
524 #size of same dictionary 'd' in bytes (which is different then above)
2) リスト付き:-
from sys import getsizeof
l = range(20)
l.__sizeof__()
100 #size of list 'l' in bytes
getsizeof(l)
116 #size of same list 'l' in bytes
3) タプル付き:-
from sys import getsizeof
t = tuple(range(20))
t.__sizeof__()
92 #size of tuple 't' in bytes
getsizeof(t)
108 #size of same tuple 't' in bytes
両方の関数のドキュメントで、オブジェクトのサイズをバイト単位で返すと書かれている場合、この種の動作の理由を教えてください。