[IronPython] IronPython.Objects.List doesn't support GetHashCode()
Timothy Fitz
firemoth at gmail.com
Thu May 12 15:44:40 CEST 2005
On 5/12/05, Chris Anderson <chrisan at gmail.com> wrote:
> 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...
Returning 1 would work, yes. Returning Object.GetHashCode won't. I
don't think suprising people with hash tables returning in linear time
is good, but people coming from other CLI languages will expect it.
> 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.
Not directly, but subclassing list and dict would work.
class HashableList:
def __hash__(self):
return id(self)
or
clash HashableList:
def __hash__(self):
return 1
To adapt simply:
HashableList(MyExistingList)
Disclaimer, I'm not sure if this works in IronPython today.
More information about the Ironpython-users
mailing list