[Python-Dev] redefining is

Tim Peters tim.one at comcast.net
Tue Mar 23 00:28:29 EST 2004


[Andrew Koenig]
> ... and I wouldn't mind it if there were a way of testing for
> substitutability that were as easy to spell as "is" -- in fact, I
> wouldn't mind if it were spelled "is" even though I realize it's
> probably impractical to do so.

It's definitely impractical to do so in the 2.3 line.  Looking beyond that,
I'm not sure we have real use cases for substitutability.  It seemed to boil
down to:

    x substitutable y =
        x is y  if x is mutable, or a mutable object is reachable
                from x, or y is mutable, or a mutable object is
                reachable from y
        x == y  otherwise (x and y are immutable, and only immutable
                objects are reachable from them)

Is that right?  It's possible I'd find that indispensable if I already had
it, but it doesn't seem likely.  What would you use it for?




More information about the Python-Dev mailing list