Dictionary Keys question
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Jan 31 02:43:28 EST 2008
On Wed, 30 Jan 2008 17:19:13 -0800, Ryszard Szopa wrote:
> BTW, can anybody explain me how is the hash function implemented in
> Python?
It calls the `__hash__()` method on the object that was given as argument.
So there's not *the* hash function, but every type implements its own.
Fallback is the hash of the identity of an object:
In [415]: class A(object): pass
.....:
In [416]: a = A()
In [417]: hash(a)
Out[417]: 161029068
In [418]: hash(id(a))
Out[418]: 161029068
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list