[Python-Dev] Fighting the theoretical randomness of "is" on immutables

Antoine Pitrou solipsis at pitrou.net
Tue May 7 00:34:04 CEST 2013

On Mon, 06 May 2013 18:23:02 -0400
Terry Jan Reedy <tjreedy at udel.edu> wrote:
> 'Item' is necessarily left vague for mutable sequences as bytearrays 
> also store values. The fact that Antoine's example 'works' for 
> bytearrays is an artifact of the caching, not a language-mandated
> necessity.

No, it isn't. You are mixing up values and references. A bytearray or a
array.array may indeed store values, but a list stores references to

I'm pretty sure that not respecting identity of objects stored in
general-purpose containers would break a *lot* of code out there.



More information about the Python-Dev mailing list