[Python-3000] callable()

Guido van Rossum guido at python.org
Wed Jul 26 05:23:54 CEST 2006


Ouch, that's a problem indeed. There's not really a clean way out
unfortunately: either we remove object.__hash__ and let hash() do the
default implementation, and then presence of __hash__ is no longer an
indicator of hashability; or we keep it, and override it to raise an
exception in unhashable types (like list.__hash__ does); or we remove
the hashability of objects by default, which lets us solve the above
problems at the cost of having a convenient hash by default.

Personally, I'm not sure this problem needs solving; I don't recall
ever needing to know whether something is hashable. So perhaps it's of
purely theoretical importance? That would suit me fine given the above
dilemma...

--Guido

On 7/23/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Guido van Rossum wrote:
> > I propose to take the same approach as for callable: if it has
> > __hash__ we consider it hashable even though the hash may fail
>
> Fair enough, although since object has __hash__
> we end up concluding that everything is
> hashable except when it isn't. :-)
>
> --
> Greg
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list