Finding size of Variable
Tim Chase
python.list at tim.thechases.com
Tue Feb 4 14:29:46 EST 2014
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
More information about the Python-list
mailing list