Hashability?

Daniel Eloff danieleloff at hotmail.com
Sun Jul 18 23:32:09 EDT 2004


Assuming a fairly normal hashtable implementation:

> why not use the object's id for the hash value.

For that to work you would need some guarantees.

1) No two different objects may have the same object id
2) All objects that compare equal must have the same object id

I doubt that this is true in the majority of cases.

Additionally, performance wise, how well distributed are these object
ids? If they are distributed poorly you can get some very bad worst case
behaviour.

Better just to make your objects hashable or wrap objects in a hashable
object.

-Dan





More information about the Python-list mailing list