is implemented with id ?

Terry Reedy tjreedy at udel.edu
Wed Sep 5 14:27:44 EDT 2012


On 9/5/2012 8:48 AM, Ramchandra Apte wrote:

> Seeing this thread, I think the is statment should be removed.
> It has a replacement syntax of id(x) == id(y)

The thread is wrong then.

If the implementation reuses ids, which CPython does,
<expression-1> is <expression-2>
must be implemented as

internal-tem1 = <expression-1>
internal-tem2 = <expression-2>
id(internal-tem1) == id(internal-tem2)

in order to ensure that the two objects exist simultaneously,
so that the id comparison is valid.

 > and "a==True" should be automatically changed into memory comparison.

I have no idea what that means.

-- 
Terry Jan Reedy




More information about the Python-list mailing list