Re: access address from object and vice versa

2012-01-23 Thread Grant Edwards
On 2012-01-22, Steven D'Aprano wrote: > On Sat, 21 Jan 2012 19:36:32 -0800, Chris Rebert wrote: > >> On Sat, Jan 21, 2012 at 7:04 PM, Tamer Higazi >> wrote: >>> Hi people! >>> I have asked myself the following thing. >>> >>> How do I access the address of an object >> >> id(obj) happens to do th

Re: access address from object and vice versa

2012-01-23 Thread Duncan Booth
Steven D'Aprano wrote: > On the other hand, presumably this means that Jython objects need an > extra field to store the ID, so the CPython approach is a space > optimization. > Given that using `id()` is such an uncommon occurence I would expect the ids to be stored outside the object in som

Re: access address from object and vice versa

2012-01-21 Thread Steven D'Aprano
On Sat, 21 Jan 2012 19:36:32 -0800, Chris Rebert wrote: > On Sat, Jan 21, 2012 at 7:04 PM, Tamer Higazi > wrote: >> Hi people! >> I have asked myself the following thing. >> >> How do I access the address of an object > > id(obj) happens to do that in CPython, but it's a mere implementation > de

Re: access address from object and vice versa

2012-01-21 Thread Steven D'Aprano
On Sun, 22 Jan 2012 04:04:08 +0100, Tamer Higazi 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 ?! Use another language. By design, Python does not provide pointers. This is a good thing,

Re: access address from object and vice versa

2012-01-21 Thread Chris Angelico
On Sun, Jan 22, 2012 at 2:04 PM, Tamer Higazi 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

Re: access address from object and vice versa

2012-01-21 Thread Chris Rebert
On Sat, Jan 21, 2012 at 7:04 PM, Tamer Higazi wrote: > Hi people! > I have asked myself the following thing. > > How do I access the address of an object id(obj) happens to do that in CPython, but it's a mere implementation detail. > and later get the object from > that address ?! Not possible.