How much memory used by a name

Diez B. Roggisch deets at nospam.web.de
Wed Feb 14 11:27:07 EST 2007


Bernard Lebel wrote:

> Hello,
> 
> I would like to know if there is a way to know how much memory (bytes,
> kilobytes, megabytes, etc) a name is using.
> 
> More specifically, I have this list of strings that I want to write to
> a file as lines.
> This list grows througout the script execution, and toward the end,
> the file is written.
> 
> However I would like to know how much memory, before writing to the
> file, is this list using. Is it possible at all?

How about summing up the individual string lengths?

total = sum(len(s) for s in my_list)


Diez



More information about the Python-list mailing list