How Python does sys.intern() works.
>>> x = '123'
>>> y = '12'
>>> y = y+'3'
# assigned new location to save it. logical as y calculated at run time.
>>> x is y
False
>>> x == y
True
# logical it is now pointing to predefined '123'.
>>> intern(y) is x
True
My question is
# adding white space in string intern is not working.
>>> x = '123 4'
>>> intern('123 4') is x
False
>>> intern('123 4') is intern(x)
True
Why need to use intern on x?
Second question.
>>> id('123 4')== id('123 4')
True
# also returns true
>>> x = '123 4'; y ='123 4'; id(x) == id(y)
True
But this same thing returns false.
>>> x = '123 4'
>>> y = '123 4'
>>> id(x) == id(y)
False
Thanks in advance. :)