Clarification on Immutability please
On Tue, Jan 28, 2020 at 1:13 AM Musbur <musbur at posteo.org> wrote:
> Am 21.01.2020 19:38 schrieb Chris Angelico:
> > Are you sure that it does? I can't reproduce this. When you slice the
> > first two from a tuple, you create a new tuple, and until the
> > assignment happens, both the new one and the original coexist, which
> > means they MUST have unique IDs.
> I'd expect that, too, but an "atomic" reassignment would not contradict
> the documentation.
The way execution works in Python, you first evaluate the object, then
assign it to the target. The new object HAS to exist before the old
one is replaced. There's no such thing as "atomic reassignment" that
simultaneously destroys the old object and assigns a new one. The
slicing will always happen first, and then the assignment.