2013年7月18日 星期四

[python]dict size

稍微做了一個測試把一個字典檔載入到dict裡面,
結構為 dict[term]=詞頻

$ ls -al /usr/local/lib/python2.7/dist-packages/jieba-0.30-py2.7.egg/jieba/dict.txt
-rw-r--r-- 1 root staff 8583143 7月 15 16:11 /usr/local/lib/python2.7/dist-packages/jieba-0.30-py2.7.egg/jieba/dict.txt

字典檔大小是 8M
生成的 python dict 是 25M
25166104

主要是由 sys.getsizeof(obj) 來計算。

所以,使用dict存放在內存內,大概膨脹了3倍的大小。

沒有留言:

張貼留言