[Python-Dev] Re: redefining is (original) (raw)
Casey Duncan casey at zope.com
Fri Mar 19 14:46:19 EST 2004
- Previous message: [Python-Dev] Re: redefining is
- Next message: [Python-Dev] Re: redefining is
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 19 Mar 2004 14:17:08 -0500 "Andrew Koenig" <ark-mlist at att.net> wrote:
> Objects are equivilant if they are the same type and their states > are the same > > Objects are interchangable if they are equivilant and their states > will always be the same (i.e., changes to one are always reflected > in the other) or if they are equivilant and immutable.
I haven't distinguished between equivalent and interchangeable. I think that most people would consider "equivalent" and "interchangeable" to mean the same thing.
I hadn't either until I read your variation.
It seems to me that given:
a = ([], []) b = ([], [])
That a and b are equivilant (their states are the same), but they are not interchangeable since a may diverge from b by mutating one different from the other.
The key of course it how you define state equality. In my view state equality means that if you were to serialize the objects to byte streams, which neutrally represented the entirety of the state, equivilant objects would have identical serializations.
That says nothing about the relationship between a and b (they may be the same objects or completely unrelated in any way). Interchangeable says that the objects are equivilant now and are related in such a way that they will always be equivilant.
Now whether a separation of equivilance and interchangability is useful beyond mental masturbation remains to be seen. It seems to me that from a pragmatic perspective, interchangeability is easier to implement especially for mutable and composite objects. Of course for immutable simple objects they mean the same thing, and equivilance is determined by directly comparing values in memory.
-Casey
- Previous message: [Python-Dev] Re: redefining is
- Next message: [Python-Dev] Re: redefining is
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]