Re: hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-29 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-03-29 03:37: *Almost* all ints are fixed points for the hashing function in the sense that hash(some_int) == some_int. Almost all as: >>> hash(-1) -2 Any idea why -1 is the sole exception? [warning: beginners, skip this. Completely inconsequential CPython d

Re: hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-29 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-29 03:14: Quoting Brian van den Broek <[EMAIL PROTECTED]>: I had thought lookup was by hash value, and thus expected the access to some_dict to cause troubles. Yet it worked. Is it that lookup is by hash value, and then equality if need be so as

Re: hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-29 Thread Danny Yoo
> *Almost* all ints are fixed points for the hashing function in the > sense that hash(some_int) == some_int. Almost all as: > > >>> hash(-1) > -2 > > Any idea why -1 is the sole exception? [warning: beginners, skip this. Completely inconsequential CPython detail ahead.] Hi Brian, Yeah, I reme

Re: hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-29 Thread jfouhy
Quoting Brian van den Broek <[EMAIL PROTECTED]>: > I had thought lookup was by hash value, and thus expected the access > to some_dict to cause troubles. Yet it worked. Is it that lookup is by > hash value, and then equality if need be so as to settle ambiguity, or > have I completely misunders

hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-28 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-03-28 14:33: I know I'm rushing this, so please feel free to ask more questions about this. Hi Danny, Orri, and all, I'm really glad Orri raised the hashing issues he did, and appreciate your informative posts, Danny. :-) There are some related things I'v

Re: [Tutor] hash()ing a list

2005-03-28 Thread Orri Ganel
Well, what I ended up doing is making it so that Nodes are equal if they have the same 'cargo', but hash based on memory address. If this wasn't the case, I either wouldn't be able to have multiple Nodes with the same 'cargo' in a LinkedList, or I wouldn't be able to sort them properly, among othe

Re: [Tutor] hash()ing a list

2005-03-28 Thread Danny Yoo
On Sun, 27 Mar 2005, Orri Ganel wrote: > So, any class that has 'rich comparison methods' defined is unhashable? > What gives? (See '[Tutor] unhashable objects') Hi Orri, If we change what it means for two objects to be equal, hashing won't work in a nice way until we also make hashing take e

Re: [Tutor] hash()ing a list

2005-03-27 Thread Orri Ganel
So, any class that has 'rich comparison methods' defined is unhashable? What gives? (See '[Tutor] unhashable objects') On Sun, 27 Mar 2005 12:38:09 -0800 (PST), Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Sun, 27 Mar 2005, Orri Ganel wrote: > > > While I do not have a pressing need to hash a

Re: [Tutor] hash()ing a list

2005-03-27 Thread Danny Yoo
On Sun, 27 Mar 2005, Orri Ganel wrote: > While I do not have a pressing need to hash a list, I am curious as to > why, if lists are unhashable, there is a __hash__() method in the list > class, which also does not work on lists, but results in a 'TypeError: > list objects are unhashable'. What'

[Tutor] hash()ing a list

2005-03-27 Thread Orri Ganel
Hello all, While I do not have a pressing need to hash a list, I am curious as to why, if lists are unhashable, there is a __hash__() method in the list class, which also does not work on lists, but results in a 'TypeError: list objects are unhashable'. What's the point of including a __hash__()