Re: Strange behaviour of 'is'

2006-09-22 Thread Ben Finney
Steve Holden <[EMAIL PROTECTED]> writes: > Perfectly all right: you make the point very well that the behavior is > an implementation artifact and not a language feature. And for those who may be thinking "oh, so I can at least depend on the behaviour within a particular implementation", that's

Re: Strange behaviour of 'is'

2006-09-22 Thread Steve Holden
Duncan Booth wrote: > Steve Holden <[EMAIL PROTECTED]> wrote: > > >>Absolutely correct. It would be more interesting to discuss how the >>output from these statements varied between (say) CPython, Jython and >>Iron Python. At the moment the discussion is indeed about insignificant >>implementa

Re: Strange behaviour of 'is'

2006-09-22 Thread Duncan Booth
Steve Holden <[EMAIL PROTECTED]> wrote: > Absolutely correct. It would be more interesting to discuss how the > output from these statements varied between (say) CPython, Jython and > Iron Python. At the moment the discussion is indeed about insignificant > implementation trivia. CPython seems

Re: Strange behaviour of 'is'

2006-09-21 Thread Steve Holden
Ben Finney wrote: > "Fijoy George" <[EMAIL PROTECTED]> writes: > > >>I am a bit perplexed by the following behaviour of the 'is' comparator > > > In summary: you are seeing implementation details that the language > specification explicitly allows to vary by implementation. > > >>My understan

Re: Strange behaviour of 'is'

2006-09-21 Thread Ben Finney
"Fijoy George" <[EMAIL PROTECTED]> writes: > I am a bit perplexed by the following behaviour of the 'is' comparator In summary: you are seeing implementation details that the language specification explicitly allows to vary by implementation. > My understanding was that every literal is a constr

Re: Strange behaviour of 'is'

2006-09-21 Thread Erik Max Francis
Ben C wrote: > I'm as baffled as you, even more so its implication: There is no implication whatsoever. Whether immutable objects are recycled by the compiler or not is totally implementation dependent, and an irrelevant implementation detail. Since they can't be mutated, whether their ident

Re: Strange behaviour of 'is'

2006-09-21 Thread Klaas
Ben C wrote: > On 2006-09-21, Fijoy George <[EMAIL PROTECTED]> wrote: > > But my understanding does not explain the result of the second comparison. > > According to the experiment, y[0] and y[1] are the same object! > > I'm as baffled as you, even more so its implication: > >>> a = 2. > >>> b =

Re: Strange behaviour of 'is'

2006-09-21 Thread Ben C
On 2006-09-21, Fijoy George <[EMAIL PROTECTED]> wrote: > Hi all, > > I am a bit perplexed by the following behaviour of the 'is' comparator > x = 2. x is 2. > False y = [2., 2.] y[0] is y[1] > True > > My understanding was that every literal is a constructure of an object. > Th

Re: Strange behaviour of 'is'

2006-09-21 Thread Duncan Booth
"Fijoy George" <[EMAIL PROTECTED]> wrote: > My understanding was that every literal is a constructure of an > object. Thus, the '2.' in 'x = 2.' and the '2.' in 'x is 2.' are > different objects. Therefore, the comparison yields false. What gave you that idea? The compiler may or may not fold tog

Strange behaviour of 'is'

2006-09-21 Thread Fijoy George
Hi all, I am a bit perplexed by the following behaviour of the 'is' comparator >>> x = 2. >>> x is 2. False >>> y = [2., 2.] >>> y[0] is y[1] True My understanding was that every literal is a constructure of an object. Thus, the '2.' in 'x = 2.' and the '2.' in 'x is 2.' are different objects.