Bernard Lim wrote: > Hi, > > I'm reading the Python Reference Manual in order to gain a better > understanding > of Python under the hood. > > On the last paragraph of 3.1, there is a statement on immutable and mutable > types as such: > > <paraphrase> > Depending on implementation, for immutable types, operations that compute > new values may or may not actually return a reference to any existing object > with the same type and value, while for mutable objects this is (strictly)? > not allowed. > </paraphrase> > > Using the example given in 3.1, how do I verify that this is true pertaining > to immutable types? Below is my understanding on verifying the above > statement: > > >>> a = 1 > >>> b = 1 > >>> a is b > True > >>> id(a) > 10901000 > >>> id(b) > 10901000 > > Is this correct?
Yes, that's correct. However, >>> a = 100 >>> b = 100 >>> a is b False >>> id(a) 135644988 >>> id(b) 135645000 -- http://mail.python.org/mailman/listinfo/python-list