Finding size of Variable

Tim Golden mail at timgolden.me.uk
Tue Feb 4 14:28:41 EST 2014


On 04/02/2014 19:21, Dave Angel wrote:
> Ayushi Dalmia <ayushidalmia2604 at gmail.com> Wrote in message:
>>>>> Where am I going wrong? What are the alternatives I can try?
>> You've rejected all the alternatives so far without showing your
> code, or even properly specifying your problem.
>> To get the "total" size of a list of strings, try (untested):
>> a = sys.getsizeof (mylist )
> for item in mylist:
> a += sys.getsizeof (item)

The documentation for sys.getsizeof:
 http://docs.python.org/dev/library/sys#sys.getsizeof
warns about the limitations of this function when applied to a 
container, and even points to a recipe by Raymond Hettinger which 
attempts to do a more complete job.
TJG


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /