A question on modification of a list via a function invocation
Marko Rauhamaa
marko at pacujo.net
Fri Sep 8 02:04:26 EDT 2017
Gregory Ewing <greg.ewing at canterbury.ac.nz>:
> There is more leeway when it comes to immutable objects;
> implementations are free to cache and re-use them, so well-written
> code avoids depending on the result of "is" for immutable objects.
I definitely trust that:
a = b
assert a is b
even when b holds an immutable object.
Assignment, argument passing, return value passing and yield (to name a
few) must preserve identity.
Marko
More information about the Python-list
mailing list