Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-27 Thread Noam Raphael
On 11/27/05, Martin v. Löwis [EMAIL PROTECTED] wrote: Noam Raphael wrote: I would greatly appreciate repliers that find a tiny bit of reason in what I said (even if they don't agree), and not deny it all as a complete load of rubbish. I don't understand what your message is. With this

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-27 Thread Noam Raphael
On 11/27/05, Samuele Pedroni [EMAIL PROTECTED] wrote: well, this still belongs to comp.lang.python. ... not if you think python-dev is a forum for such discussions on OO thinking vs other paradigms. Perhaps my style made it look like a discussion on OO thinking vs other paradigms, but my

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-27 Thread Armin Rigo
Hi Noam, On Sun, Nov 27, 2005 at 09:04:25PM +0200, Noam Raphael wrote: No, I meant real programming examples. My theory is that most user-defined classes have a value, and those that don't are related to I/O, in some sort of a broad definition of the term. I may be wrong, so I ask for

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-26 Thread Noam Raphael
Three weeks ago, I read this and thought, well, you have two options for a default comparison, one based on identity and one on value, both are useful sometimes and Guido prefers identity, and it's OK. But today I understood that I still think otherwise. In two sentences: sometimes you wish to

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-26 Thread Martin v. Löwis
Noam Raphael wrote: I would greatly appreciate repliers that find a tiny bit of reason in what I said (even if they don't agree), and not deny it all as a complete load of rubbish. I don't understand what your message is. With this posting, did you suggest that somebody does something

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-26 Thread Samuele Pedroni
Noam Raphael wrote: Three weeks ago, I read this and thought, well, you have two options for a default comparison, one based on identity and one on value, both are useful sometimes and Guido prefers identity, and it's OK. But today I understood that I still think otherwise. well, this still

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-26 Thread Adam Olsen
On 11/26/05, Noam Raphael [EMAIL PROTECTED] wrote: [...stuff about using Ref() for identity dictionaries...] I too have thought along these lines, but I went one step further. There is an existing function that could be modified to produce Ref objects: id(). Making id() into a type allows it

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-26 Thread Nick Coghlan
Adam Olsen wrote: On 11/26/05, Noam Raphael [EMAIL PROTECTED] wrote: [...stuff about using Ref() for identity dictionaries...] I too have thought along these lines, but I went one step further. There is an existing function that could be modified to produce Ref objects: id(). Making

[Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-08 Thread Technical Support of Intercable Co
Why 'identity' objects can't define: def __getKey__(self): return Key(self, id(self)) Then they would act as usually, while value object can define def __getKey__(self): return Key(self, self.i, self.j, self.a[1]) (Key is an abstraction to handle subclassing) Of course,

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-07 Thread Guido van Rossum
Two more thoughts in this thread. (1) The key idiom is a great pattern but I don't think it would work well to make it a standard language API. (2) I'm changing my mind about the default hash(). The original default hash() (which would raise TypeError if __eq__ was overridden but __hash__ was

[Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Jim Fulton
The recent discussion about what the default hash and equality comparisons should do makes me want to chime in. IMO, the provision of defaults for hash, eq and other comparisons was a mistake. I'm especially sensitive to this because I do a lot of work with persistent data that outlives program

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Guido van Rossum
On 11/6/05, Jim Fulton [EMAIL PROTECTED] wrote: IMO, the provision of defaults for hash, eq and other comparisons was a mistake. I agree with you for 66%. Default hash and inequalities were a mistake. But I wouldn't want to do without a default ==/!= implementation (and of course it should be

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Jim Fulton
Guido van Rossum wrote: On 11/6/05, Jim Fulton [EMAIL PROTECTED] wrote: ... Except that I really don't think that there's anything wrong with a default __eq__ that uses object identity. As Martin pointed out, it's just too weird that an object wouldn't be considered equal to itself. It's

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread John Williams
(This is kind of on a tangent to the original discussion, but I don't want to create yet another subject line about object comparisons.) Lately I've found that virtually all my implementations of __cmp__, __hash__, etc. can be factored into this form inspired by the key parameter to the

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Guido van Rossum
On 11/6/05, John Williams [EMAIL PROTECTED] wrote: (This is kind of on a tangent to the original discussion, but I don't want to create yet another subject line about object comparisons.) Lately I've found that virtually all my implementations of __cmp__, __hash__, etc. can be factored into

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Phillip J. Eby
At 12:58 PM 11/6/2005 -0800, Guido van Rossum wrote: The main way this breaks down is when comparing objects of different types. While most comparisons typically are defined in terms of comparisons on simpler or contained objects, two objects of different types that happen to have the same key

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Guido van Rossum
On 11/6/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 12:58 PM 11/6/2005 -0800, Guido van Rossum wrote: The main way this breaks down is when comparing objects of different types. While most comparisons typically are defined in terms of comparisons on simpler or contained objects, two objects

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Josh Hoyt
On 11/6/05, Guido van Rossum [EMAIL PROTECTED] wrote: On 11/6/05, Phillip J. Eby [EMAIL PROTECTED] wrote: When I use this pattern, I often just include the object's type in the key. (I call it the 'hashcmp' value, but otherwise it's the same pattern.) But how do you make that work with

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Josiah Carlson
John Williams [EMAIL PROTECTED] wrote: (This is kind of on a tangent to the original discussion, but I don't want to create yet another subject line about object comparisons.) Lately I've found that virtually all my implementations of __cmp__, __hash__, etc. can be factored into this

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Phillip J. Eby
At 01:29 PM 11/6/2005 -0800, Guido van Rossum wrote: On 11/6/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 12:58 PM 11/6/2005 -0800, Guido van Rossum wrote: The main way this breaks down is when comparing objects of different types. While most comparisons typically are defined in terms of

Re: [Python-Dev] For Python 3k, drop default/implicit hash, and comparison

2005-11-06 Thread Phillip J. Eby
At 07:12 PM 11/6/2005 -0500, Phillip J. Eby wrote: At 01:29 PM 11/6/2005 -0800, Guido van Rossum wrote: On 11/6/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 12:58 PM 11/6/2005 -0800, Guido van Rossum wrote: The main way this breaks down is when comparing objects of different types.