This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients ashwch, benrg, docs@python, ezio.melotti, r.david.murray
Date 2013-01-24.03:37:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1358998635.73.0.478702263053.issue16701@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.)
History
Date User Action Args
2013-01-24 03:37:15ezio.melottisetrecipients: + ezio.melotti, r.david.murray, docs@python, benrg, ashwch
2013-01-24 03:37:15ezio.melottisetmessageid: <1358998635.73.0.478702263053.issue16701@psf.upfronthosting.co.za>
2013-01-24 03:37:15ezio.melottilinkissue16701 messages
2013-01-24 03:37:15ezio.melotticreate