KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I just experimented with the size of python data structures in memory. I wrote the following snippet: import sys lst1=[] lst1.append(1) lst2=[1] print(sys.getsizeof(lst1), sys.getsizeof(lst2)) I got the following outputs on the following configurations: Windows 7 64bit, Python3.1: 52 40 (so lst1 has 52 bytes and lst2 has 40 bytes) Ubuntu 11.4 32bit with Python3.2: output is 48 32 Ubuntu 11.4 32bit Python2.7: 48 36 Can anyone explain to me why the two sizes differ although both are lists containing a 1? In the python documentation for the getsizeof function I found the following: ...adds an additional garbage collector overhead if the object is managed by the garbage collector. Could this be the case in my little example?
Tags (comma-separated)
Save Edits
Cancel