Hi, Python docs says that id function returns the unique id for an object.
>>> id(10) 165936452 >>> a=10 >>> id(a) 165936452 >>> b = int(10) >>> id(b) 165936452 >>> x = tuple() >>> y=tuple() >>> id(x) -1208311764 >>> id(y) -1208311764 >>> l = list() >>> m = list() >>> id(l) -1210839956 >>> id(m) -1210839700 >From the above example, id(mutable_object) returns different ids, but id(immutable_object) return always the same id. If I try to create new immutable object, It is just returning the existed object instead of creating new. How does it internally manages to return the same object? Why it is not creating new object if it is immutable? What about this below case? >>> id((1,)) -1208770004 >>> id((1,)) -1208770004 >>> a=(1,) >>> id(a) -1208745460 >>> id((1,)) -1208759028 Why is id changes here even if it is a tuple(immutable). _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers