I'll be the first to admit that I'm not the master of language design or hashtables...
My understanding was that the hash of an object needed to be consistent over the life of the object (therefore providing a way for a hashtable to find the bucket for it) and relatively unique (basically, that given a number of objects they don't all hash to the same thing).
I believe that simply returning "1" from GetHashCode() would work just fine - however it would mean that hashtables would effectively become linked lists or linear arrays (depending on their implementation). From that model, returning the base CLR GetHashCode implementation for object seems completely reasonable...
The issue i'm running into is that internal data binding constructs in Avalon require that we push the data source for lists into a hashtable (so that we can manage concurrency in a reasonably performant fashion)... without hash support, i can never bind to lists or dictionaries from python.
On 5/12/05, Timothy Fitz <[EMAIL PROTECTED]> wrote:
> On 5/12/05, Chris Anderson <[EMAIL PROTECTED]> wrote:
<snip />
> Yes, there is harm in it. Try this in python hash([]) and you'll get
> the same TypeError. The reason is because lists shouldn't be hashed.
> List comparison is based on the items inside a list, not the instance
> of the list itself. For instance:
>
> from copy import deepcopy
> A = [1,2]
> B = deepcopy(A)
> assert A == B
> assert id(A) != id(B)
>
<snip />
> In general, mutable objects should not provide hashing functions in python.
<snip />
On 5/12/05, Timothy Fitz <[EMAIL PROTECTED]> wrote:
> On 5/12/05, Chris Anderson <[EMAIL PROTECTED]> wrote:
<snip />
> Yes, there is harm in it. Try this in python hash([]) and you'll get
> the same TypeError. The reason is because lists shouldn't be hashed.
> List comparison is based on the items inside a list, not the instance
> of the list itself. For instance:
>
> from copy import deepcopy
> A = [1,2]
> B = deepcopy(A)
> assert A == B
> assert id(A) != id(B)
>
<snip />
> In general, mutable objects should not provide hashing functions in python.
<snip />
_______________________________________________ users-ironpython.com mailing list users-ironpython.com@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com