On Wed, Sep 6, 2017 at 10:11 PM, Rustom Mody <rustompm...@gmail.com> wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: >> >> >> > Can you explain what "id" and "is" without talking of memory? >> >> Yes. >> >> id() returns an abstract ID number which is guaranteed to be an integer, and >> guaranteed to be distinct for all objects which exist at the same time. When >> an >> object ceases to exist, its ID number may be re-used. >> >> `is` compares the two operands for identity. If the two operands are the same >> object, `is` returns True, if they are distinct objects, `is` returns False. > >>>> a = (1,2) >>>> b = (1,2) >>>> a is b > False >>>> x = 1 >>>> y = 1 >>>> x is y > True > > a seems to be as 'same' to b as x is to y > Python seems to think otherwise > > Evidently your ‘same’ is not the same as mine??
*facepalm* I got nothing to say to you. Have you been on this list all this time and still don't understand that Python sometimes optimizes immutables? ChrisA -- https://mail.python.org/mailman/listinfo/python-list