Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Fundamental Data Types vs Immutability:

Vinay Rawal answered on April 1, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • primitive (immutable) data types:

  • Fundamental Data Types vs Immutability:

    0

    All Fundamental Data types are immutable. i.e once we creates an object,we cannot perform any changes in that object. If we are trying to change then with those changes a new object will be created. This non-chageable behaviour is called immutability.

    ֍ In Python if a new object is required, then PVM won’t create object immediately. First it will check is any object available with the required content or not. If available then existing object will be reused. If it is not available then only a new object will be created. The advantage of this approach is memory utilization and performance will be improved.

    ֍ But the problem in this approach is, several references pointing 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. According to this once creates an object we are not allowed to change content. If we are trying to change with those changes a new object will be created. 1) >>> a=10 2) >>> b=10 3) >>> a is b 4) True 5) >>> id(a) 6) 1572353952 7) >>> id(b) 8) 1572353952 9) >>> 

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Tags: types whatever
    Link to this answer
    Share Copy Link
    Contributed on Apr 01 2023
    Vinay Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.