osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A question on modification of a list via a function invocation


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