Immutable and Mutable Types

Bernard Lim bernard at blimyk.org
Mon Mar 17 02:23:41 EDT 2008


Hi,

I'm reading the Python Reference Manual in order to gain a better understanding 
of Python under the hood.

On the last paragraph of 3.1, there is a statement on immutable and mutable 
types as such:

<paraphrase>
Depending on implementation, for immutable types, operations that compute 
new values may or may not actually return a reference to any existing object 
with the same type and value, while for mutable objects this is (strictly)? 
not allowed.
</paraphrase>

Using the example given in 3.1, how do I verify that this is true pertaining 
to immutable types? Below is my understanding on verifying the above statement:

>>> a = 1
>>> b = 1
>>> a is b
True
>>> id(a)
10901000
>>> id(b)
10901000

Is this correct?

Regards
Bernard





More information about the Python-list mailing list