Loading...
Python

Fundamental Data Types vs Immutability

Fundamental data type are immutable i.e., once we create an object, then changes cannot be performed in that object.If we try to make changes then with those changes a new object will be created. This non-changeable behavior is called as immutability.
In Python if a new object is required, then PVM first checks if any object is available content or not. If object is available then that object is reused. If it is not available then the new object will be created. This type of approach will improve the performance and the utilization of the memory.
But, the problem in this approach is, several reference points to the same object ,by using one reference if we are allowed to change the content in the existing object then the remaining references will be effected. to prevent this immutability concept is required.

Leave a Reply

Your email address will not be published. Required fields are marked *