Difference of hash and __hash__()

Jeff Epler jepler at unpythonic.net
Wed Sep 3 14:57:09 CEST 2003


On Wed, Sep 03, 2003 at 11:50:41AM +0200, Stefan Fleiter wrote:
> Hi,
> 
> Jeff Epler wrote:
> 
> >No, it's apparently deliberate that slices don't hash (so that
> >{}[1:2] raises an error).  I think that slice(None).__hash__ is from
> >object.__hash__, but this is rightfully(?) ignored by PyObject_Hash()
> >which looks at tp_hash (NULL for slice objects) and tp_compare (non-NULL
> >for slice objects) with the result that the object is treated as
> >unhashable.
> 
> So, should I write a bugreport or not?
> Are you sure it is "rightfully ignored" or not?

I'm sure that multiple python-list/c.l.python readers claim it is a feature
that hash(slice(None)) raises an exception.

http://google.com/groups?threadm=mailman.1058757391.658.python-list%40python.org

Jeff





More information about the Python-list mailing list