Help: sizeof() and reference in python?
Gene Chiaramonte
gchiaramonte at ibl.bm
Sun Mar 5 10:22:30 EST 2000
I guess I should have been more specific.
1 - I am trying to get the size of an object in bytes to monitor how much
memory a list or object occupies.
2 - I am trying to get the pointer to the memory address of an object. Much
like the array objects buffer_info(), where the second item in the returned
tuple is the pointer to the memory address of the first element of the
array.
Thanks for the help though.
Gene
> -----Original Message-----
> From: Jeff [mailto:jam at quark.emich.edu]
> Sent: Sunday, March 05, 2000 8:37 AM
> To: Gene Chiaramonte
> Subject: Re: Help: sizeof() and reference in python?
>
>
> On Sun, Mar 05, 2000 at 08:17:43AM -0400, 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.
> >
> > example in c:
> >
> > l = [1, 2, 3] #python list
> >
> > t1 = sizeof(l) // how i'd do it in c
> > t2 = &l
> >
> > Thanks,
> >
> > Gene
> >
>
> you can get the *length* of an object in python, which I suspect is the
> closest you can come to sizeof().. what are you trying to do
> with sizeof()
> that len() can't already handle?
>
> the reference thing is easy ;).. everything is a reference in
> python. so if you
> want 't2' to be a reference to 'l', you assign it as normal 't2 = l'.
>
> hope that helps..
>
> regards,
> J
> --
> || visit gfd <http://quark.emich.edu/>
> || psa member -- <http://www.python.org/psa/>
> || New Image Systems & Services, Inc. <http://www.newimage.com/>
More information about the Python-list
mailing list