Re: addressof object with id()

2013-03-24 Thread Steven D'Aprano
On Sun, 24 Mar 2013 06:54:08 +, Nobody wrote: > More generally, an implementation *may* intern any immutable value, > although it's not guaranteed to do so for anything except (IIRC) False, > True and None. I believe the same also applies to NotImplemented and Ellipsis, although I'm too lazy

Re: addressof object with id()

2013-03-24 Thread Peter Otten
Steven D'Aprano wrote: > On Sat, 23 Mar 2013 21:00:07 -0400, Roy Smith wrote: > >> In article , >> Fabian von Romberg wrote: >> >>> Hi, >>> >>> I have a single questions regarding id() built-in function. >>> >>> example 1: >>> >>> var1 = "some string" >>> var2 = "some string" >>> >>> if us

Re: addressof object with id()

2013-03-23 Thread Nobody
On Sat, 23 Mar 2013 19:37:35 -0500, Fabian von Romberg wrote: > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly the same address. I'm assuming that you used somet

Re: addressof object with id()

2013-03-23 Thread rusi
On Mar 24, 8:33 am, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 1:19 PM, Roy Smith wrote: > > In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, > >  Steven D'Aprano wrote: > > >> Those who don't do serious floating point work hate NANs > > > This kind of thing doesn't just co

Re: addressof object with id()

2013-03-23 Thread Chris Angelico
On Sun, Mar 24, 2013 at 1:19 PM, Roy Smith wrote: > In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Those who don't do serious floating point work hate NANs > > This kind of thing doesn't just come up in floating point work. SQL > folks have much

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Those who don't do serious floating point work hate NANs This kind of thing doesn't just come up in floating point work. SQL folks have much the same issue with NULL. -- http://mail.python.org/mailman/

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article <514e5e71$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > As far as I know, there is no Python implementation that automatically > interns strings which are not valid identifiers. "some string" is not a > valid identifier, due to the space. I stand corrected.

Re: addressof object with id()

2013-03-23 Thread Steven D'Aprano
On Sun, 24 Mar 2013 11:56:50 +1100, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: >> You can assume that if the id's are equal, the objects are equal. But >> you can't assume the inverse or the converse. > > To be more specific: If the ids are equal, the objects ar

Re: addressof object with id()

2013-03-23 Thread Steven D'Aprano
On Sat, 23 Mar 2013 21:00:07 -0400, Roy Smith wrote: > In article , > Fabian von Romberg wrote: > >> Hi, >> >> I have a single questions regarding id() built-in function. >> >> example 1: >> >> var1 = "some string" >> var2 = "some string" >> >> if use the id() function on both, it returns e

Re: addressof object with id()

2013-03-23 Thread Steven D'Aprano
On Sat, 23 Mar 2013 19:37:35 -0500, Fabian von Romberg wrote: > Hi, > > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly the same address. The id() function does

Re: addressof object with id()

2013-03-23 Thread Chris Angelico
On Sun, Mar 24, 2013 at 12:00 PM, Roy Smith wrote: > I had thought interning only affected > string literals, but apparently it works for all strings! This works > too: > a = "b" + "ar" b = "ba" + "r" id(a) > 3810152 id(b) > 3810152 > > but, again, none of this is guaranteed.

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article , Chris Angelico wrote: > On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: > > You can assume that if the id's are equal, the objects are equal. But you > > can't assume the inverse or the converse. > > To be more specific: If the ids are equal, the objects are identical. > Does

Re: addressof object with id()

2013-03-23 Thread Roy Smith
In article , Fabian von Romberg wrote: > Hi, > > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly the same address. Yup. This is because (in some implementatio

Re: addressof object with id()

2013-03-23 Thread Chris Angelico
On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: > You can assume that if the id's are equal, the objects are equal. But you > can't assume the inverse or the converse. To be more specific: If the ids are equal, the objects are identical. Doesn't mean they'll compare equal - for instance, flo

Re: addressof object with id()

2013-03-23 Thread Dave Angel
On 03/23/2013 08:37 PM, Fabian von Romberg wrote: Hi, I have a single questions regarding id() built-in function. example 1: var1 = "some string" var2 = "some string" if use the id() function on both, it returns exactly the same address. example 2: data = "some string" var1 = data var2 = d