2

I understand that python internally using the string interning concept to map same string in a particular memory location, and that helps in a way to optimise the memory.

>>> a = 'a'
>>> id(a)
>>> 4503208208
>>> b = 'a'
>>> id(b)
>>> 4503208208

But why does special character in a string is handled differently

>>> i = 'a.'
>>> id(i)
>>> 4519365240
>>> j='a.'
>>> id(j)
>>> 4519463824

Why is the same logic and principle not implemented when there is a special character in the string?

Arghya Saha
  • 5,599
  • 4
  • 26
  • 48

0 Answers0