A
Ayushi Dalmia
Ayushi Dalmia said:This also doesn't gives the true size. I did the following:On 2014-02-04 14:21, Dave Angel wrote:
To get the "total" size of a list of strings, try (untested):
a = sys.getsizeof (mylist )
for item in mylist:
a += sys.getsizeof (item)
I always find this sort of accumulation weird (well, at least in
Python; it's the *only* way in many other languages) and would write
it as
a = getsizeof(mylist) + sum(getsizeof(item) for item in mylist)
-tkc
import sysdata=[]f=open('stopWords.txt','r')
for line in f:line=line.split()data.extend(line)
print sys.getsizeof(data)
Did you actually READ either of my posts or Tim's? For a
container, you can't just use getsizeof on the container.
a = sys.getsizeof (data)
for item in mylist:
a += sys.getsizeof (data)
print a
Yes, I did. I now understand how to find the size.