Ezio Melotti added the comment:

> What is "when possible" supposed to mean here?

Generally it means "when the object is mutable":
>>> l = [1,2,3]
>>> id(l)
3074713484
>>> l += [4]
>>> id(l)
3074713484
>>> t = (1,2,3)
>>> id(t)
3074704004
>>> t += (4,)
>>> id(t)
3075304860

Tuples are not mutable, so it's not possible to modify them in place, and a new 
tuple needs to be created.
Note that while most mutable objects in the stdlib that support += do indeed 
modify the object rather than creating a new one, I don't think this is 
strictly required.
IOW that paragraph is already warning you that (with mutable objects) the 
object might be reused, depending on the implementation.  Maybe this should be 
clarified?
(IIRC in CPython it could be possible that in some situations an immutable 
object still has the same id after an augmented assignment, but, if it really 
happens, it is an implementation detail and shouldn't affect semantics.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16701>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to