Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19202 > unrolled thread

Re: access address from object and vice versa

Started byChris Angelico <rosuav@gmail.com>
First post2012-01-22 15:55 +1100
Last post2012-01-22 15:55 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: access address from object and vice versa Chris Angelico <rosuav@gmail.com> - 2012-01-22 15:55 +1100

#19202 — Re: access address from object and vice versa

FromChris Angelico <rosuav@gmail.com>
Date2012-01-22 15:55 +1100
SubjectRe: access address from object and vice versa
Message-ID<mailman.4919.1327208121.27778.python-list@python.org>
On Sun, Jan 22, 2012 at 2:04 PM, Tamer Higazi <th982a@googlemail.com> wrote:
> Hi people!
> I have asked myself the following thing.
>
> How do I access the address of an object and later get the object from
> that address ?!

The problem with that sort of idea is that it mucks up garbage
collection. CPython, for example, maintains a reference count for
every object; your address is, in a sense, another reference, but one
that the GC doesn't know about - so it might release the object and
reuse the memory.

What you can do, though, is simply have another name bound to the same
object. You can then manipulate the object through that name, and
it'll function just like a pointer would in C. The original name and
the new name will function exactly the same.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web