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

Antoine Pitrou solipsis at pitrou.net
Tue May 7 08:25:57 CEST 2013

On Mon, 06 May 2013 22:50:55 -0400
Terry Jan Reedy <tjreedy at udel.edu> wrote:
> > A bytearray or a array.array may indeed store values, but a list stores references to
> > objects.
> I said exactly that in reference to CPython. As far as I know, the same 
> is true of lists in every other implementation up until Pypy decided to 
> optimize that away. What I also said is that I cannot read the *current* 
> doc as guaranteeing that characterization.

In the absence of more precise specification, the reference is IMO the
reference interpreter, a.k.a. CPython, and its behaviour is more than
well-known and stable over time here.

> > I'm pretty sure that not respecting identity of objects stored in
> > general-purpose containers would break a *lot* of code out there.
> Me too. Hence I suggested that if lists, etc, are intended to respect 
> identity, with 'is' as currently defined, in any implementation, then 
> the docs should say so and end the discussion. I would be happy to 
> commit an approved patch, but I am not in a position to decide the 
> substantive content.

For me, a patch that mandated general-purpose containers (list, dict,
etc.) respect object identity would be ok.



More information about the Python-Dev mailing list