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


Groups > comp.lang.python > #19202

Re: access address from object and vice versa

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'memory.': 0.05; 'pointer': 0.05; 'subject:object': 0.07; 'garbage': 0.09; 'manipulate': 0.09; 'object;': 0.09; 'subject:access': 0.09; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'subject:address': 0.15; 'cpython,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'later': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'asked': 0.23; 'do,': 0.25; 'pm,': 0.26; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'problem': 0.29; '22,': 0.30; 'object.': 0.30; 'sun,': 0.30; 'idea': 0.32; 'sort': 0.32; 'to:addr:python-list': 0.33; 'object': 0.33; 'maintains': 0.34; 'sense,': 0.34; 'example,': 0.36; 'bound': 0.36; 'reference': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'received:209.85': 0.38; 'same.': 0.38; 'subject:from': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'your': 0.61; 'address': 0.61
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=AQAomg5Yc50aXWZa2FHtQ7vqHdkwvrijEM139f2rWE4=; b=QzKqP50gaoPFPJ2Wb9dJgdKm6g25xw53fSA04KqAz6zi4ryqUUmAC7+Db8NDVKTwkF mJxsG9TPL9pr6wBHirmPRPfoZkhb4nbk+K32Yn27Jb/xDA3JuDa994t2FkMSqrc6uqJf ccaYTFEZzc3/pQrPB5zZWIsHkN1ueuc0SZjW4=
MIME-Version 1.0
In-Reply-To <4F1B7CA8.80702@googlemail.com>
References <4F1B7CA8.80702@googlemail.com>
Date Sun, 22 Jan 2012 15:55:19 +1100
Subject Re: access address from object and vice versa
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4919.1327208121.27778.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1327208121 news.xs4all.nl 6981 [2001:888:2000:d::a6]:39213
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19202

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web