Re: Address of an immutable object

2010-05-30 Thread Steven D'Aprano
On Sun, 30 May 2010 22:08:49 +0200, candide wrote: > Alf P. Steinbach a écrit : >> * candide, on 30.05.2010 19:38: >>> Suppose a Python program defines an integer object with value 42. The >>> object has an "address" we can capture with the built-in function id() >>> : > >> First, id() doesn't ge

Re: Address of an immutable object

2010-05-30 Thread candide
Alf P. Steinbach a écrit : * candide, on 30.05.2010 19:38: Suppose a Python program defines an integer object with value 42. The object has an "address" we can capture with the built-in function id() : First, id() doesn't generally provide an address. I talked about a quote unquote "address

Re: Address of an immutable object

2010-05-30 Thread candide
Thanks for your responses, I should do more experiments ! -- http://mail.python.org/mailman/listinfo/python-list

Re: Address of an immutable object

2010-05-30 Thread Simon Brunning
On 30 May 2010 18:38:23 UTC+1, candide wrote: > Two non mutable objects with the same value shall be allocated at a constant > and unique address ? Nope. >>> a = 999 >>> b = 999 >>> id(a) == id(b) False Your statement will be the case for small integers, but this in an implementation detail. I

Re: Address of an immutable object

2010-05-30 Thread Alf P. Steinbach
* candide, on 30.05.2010 19:38: Suppose a Python program defines an integer object with value 42. The object has an "address" we can capture with the built-in function id() : >>> a=42 >>> id(a) 152263540 >>> Now I was wondering if any integer object with value 42 will be refered at the same

Address of an immutable object

2010-05-30 Thread candide
Suppose a Python program defines an integer object with value 42. The object has an "address" we can capture with the built-in function id() : >>> a=42 >>> id(a) 152263540 >>> Now I was wondering if any integer object with value 42 will be refered at the same adress with the above id. Some e