Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-07 Thread BJörn Lindqvist
How would the value equality operator deal with recursive objects? class Foo: def __init__(self): self.foo = self Seems to me that it would take atleast some special-casing to get Foo() == Foo() to evalute to True in this case... -- mvh Björn

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-07 Thread Martin v. Löwis
BJörn Lindqvist wrote: How would the value equality operator deal with recursive objects? class Foo: def __init__(self): self.foo = self Seems to me that it would take atleast some special-casing to get Foo() == Foo() to evalute to True in this case... This is sort-of

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-07 Thread Michael Hudson
Martin v. Löwis [EMAIL PROTECTED] writes: BJörn Lindqvist wrote: How would the value equality operator deal with recursive objects? class Foo: def __init__(self): self.foo = self Seems to me that it would take atleast some special-casing to get Foo() == Foo() to evalute to

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-07 Thread Ronald Oussoren
On 7-nov-2005, at 23:34, Martin v. Löwis wrote: BJörn Lindqvist wrote: How would the value equality operator deal with recursive objects? class Foo: def __init__(self): self.foo = self Seems to me that it would take atleast some special-casing to get Foo() == Foo() to

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-05 Thread Noam Raphael
On 11/3/05, Josiah Carlson [EMAIL PROTECTED] wrote: ... Right, but lists (dicts, tuples, etc.) are defined as containers, and their comparison operation is defined on their contents. Objects are not defined as containers in the general case, so defining comparisons based on their contents

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-05 Thread Josiah Carlson
Noam Raphael [EMAIL PROTECTED] wrote: On 11/3/05, Josiah Carlson [EMAIL PROTECTED] wrote: To summarize, I think that value-based equality testing would usually be what you want, and currently implementing it is a bit of a pain. Actually, implementing value-based equality testing, when

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-05 Thread Noam Raphael
On 11/5/05, Josiah Carlson [EMAIL PROTECTED] wrote: ... 1. It doesn't add complexity, or a new builtin. It changes default behavior (which I specified as a portion of my statement, which you quote. And you are wrong, it adds complexity to the implementation of both class instantiation and

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-05 Thread Josiah Carlson
Noam Raphael [EMAIL PROTECTED] wrote: On 11/5/05, Josiah Carlson [EMAIL PROTECTED] wrote: ... 1. It doesn't add complexity, or a new builtin. It changes default behavior (which I specified as a portion of my statement, which you quote. And you are wrong, it adds complexity to the

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-05 Thread Noam Raphael
On 11/6/05, Josiah Carlson [EMAIL PROTECTED] wrote: ... Sorry, I meant complexity to the Python user - it won't require him to learn more in order to write programs in Python. Ahh, but it does add complexity. Along with knowing __doc__, __slots__, __metaclass__, __init__, __new__,

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-05 Thread Josiah Carlson
Noam Raphael [EMAIL PROTECTED] wrote: On 11/6/05, Josiah Carlson [EMAIL PROTECTED] wrote: ... Sorry, I meant complexity to the Python user - it won't require him to learn more in order to write programs in Python. You are right. But that's Python - I think that nobody knows all the

[Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-02 Thread Noam Raphael
I think it should. (I copy here messages from the thread about the default hash method.) On 11/2/05, Michael Chermside [EMAIL PROTECTED] wrote: Why not make the default __eq__ really compare the objects, that is, their dicts and their slot-members? Short answer: not the desired behavior.

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-02 Thread Noam Raphael
I've looked for classes in my /usr/lib/python2.4 directory. I won't go over all the 7346 classes that were found there, but let's see: identity objects that will continue to work because they contain other identity objects SocketServer, and everything which inherits from

Re: [Python-Dev] Should the default equality operator compare values instead of identities?

2005-11-02 Thread Josiah Carlson
Noam Raphael [EMAIL PROTECTED] wrote: On 11/2/05, Josiah Carlson [EMAIL PROTECTED] wrote: I believe the current behavior of __eq__ is more desireable than comparing contents, as this may result in undesireable behavior (recursive compares on large nested objects are now slow, which used to