In Python:
>>> a = "Hello"
>>> b = "Hello"
>>> id(a) == id(b)
True
Why? Can this create a problem in a complex programs which refer to the memory locations of the object?
From the Python documentation
For immutable types [like strings], operations that compute new values may actually return a reference to any existing object with the same type and value. E.g., after
a = 1; b = 1,aandbmay or may not refer to the same object with the value one, depending on the implementation...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With