Tuple assignment and generators?

vdrab stijndesaeger at gmail.com
Fri May 5 12:22:57 CEST 2006


>
language reference, objects:

    "Even the importance of object identity is affected in some sense:
for
    immutable types, operations that compute new values may actually
    return a reference to any existing object with the same type and
value,
    while for mutable objects this is not allowed. E.g., after "a = 1;
b = 1",
    a and b may or may not refer to the same object with the value one,
    depending on the implementation, but after "c = []; d = []", c and
d are
    guaranteed to refer to two different, unique, newly created empty
lists.

(note the use of "may or may not" and "depending on the
implementation")

</F>

That, I knew. What I did not know, nor get from this explanation, is
that this behaviour "may" differ
not only within the same implementation, but with instances of the same
class or type (in this case, 'int'). Is this really a case of me being
too dumb or too lazy, or could it just be that this behaviour is not
all that consistent ?
v.
v.




More information about the Python-list mailing list