strings immutable , id values for strings - Python | Python Tutorial for Beginners in telugu Part 12

preview_player
Показать описание
#ottit #pythontutorial
Is Strings in python Immutable ? How?

String is immutable : on each modification of the string content a new string variable is created as name same as old string variable name with new modified content. Old string variable is deleted from memory. It seems to be string modified , but re-created using old name with new content. It can be identified by checking id value of the stings before and after modifications.

Each string object is identified by unique id value, irrespective of the type of content in it. When the string variables are with same content including case (lower case and upper case) for that variables , id values are same.

In simple words , variables with same content in all aspects like type , size , case then that variables with same id.

Memory optimization and performance.
Рекомендации по теме