peter at engcorp.com
Mon Sep 22 22:28:37 CEST 2003
"Batista, Facundo" wrote:
> #- Can you provide more background on the specific problem you need
> #- to solve, or are you looking for a very general solution? In
> #- other words, do you just need to know how much memory a list, or
> #- an integer uses up, or do you think you need a general-purpose
> #- function which works with any object of any type.
> It's a very general question for a very particular problem, :)
> My particular problem is that I want to store in memory a pickled object,
> and then want to know if that object changed.
Knowing how much memory the object consumes will not help you with
that, at least in general. The object could easily be changed in a
dozen ways yet still consume the same amount of memory.
> Don't know if there's a better solution for this particular problem
> (suggestions welcomed)
Can't the object just track changes to itself? This is a fairly
common solution to the general problem you describe. Resorting to
things like checking memory consumption is not likely the best way
to approach this.
> but it still remains a general question: the other
> day I wanted to know "how much more expensive in memory is a list than a
> tuple for a given content".
I believe the answer was given, but in case it wasn't: they take
effectively the same amount of memory, as each is basically a series
of pointers to other objects.
More information about the Python-list