Help: sizeof() and reference in python?
gchiaramonte at ibl.bm
Mon Mar 6 09:53:26 CET 2000
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Ken Seehof
> Sent: Sunday, March 05, 2000 5:40 PM
> To: python-list at python.org
> Subject: Re: Help: sizeof() and reference in python?
> Gene Chiaramonte wrote:
> > Is there a way to get the size of an object in python? I'd also
> like to get
> > a reference to an object.
> Yeah, but you'd have to write it as a C extension and it would be a
> rather difficult project. I wonder if this has been done. In a
> language like python, people rarely need things like sizeof.
When working with large datasets, I need to monitor memory usage, so I can
warn a user about impending doom before it happens and they call me
screaming that my program sucks. Thus, I can tell them they suck first.
> > example in c:
> > l = [1, 2, 3] #python list
> > t1 = sizeof(l) // how i'd do it in c
> Be careful: The python list is implemented as an array of
> pointersto objects.
> In this case, the objects are pre-allocated integer constants
> (because they are small), and in any case the objects themselves are
> not part of the memory usage of the list.
> > t2 = &l
> Everything is a reference already (if you are thinking
> low-level).But this is
> misleading because '=' is not an assignment operator,
> (except when following a subscript, or in some cases an attribute).
> If you are confused by what I am saying, that's a good start.
> I recommend spending some quality time with your interpreter
> trying different things till you understand exactly what '=' does.
That was just psudo code to express my idea in a way all of us bit-heads
could understand. I am fairly comfortable with using '='. (I'm still working
on the swap thing: a, b = b, a though)
You bring up a good point though. Something often overlooked by python
newbies is the interperter. I'm addicted to the thing and no longer find
write-compile-run-test programming languages enjoyable to use.
Thanks for your help.
> > Thanks,
> > Gene
More information about the Python-list