[Numpy-discussion] Implementing hashing protocol for dtypes

David Cournapeau david@ar.media.kyoto-u.ac...
Thu Mar 12 08:15:43 CDT 2009


Stéfan van der Walt wrote:
> 2009/3/12 David Cournapeau <cournape@gmail.com>:
>   
>> Anyway, here is a first shot at it:
>>
>> http://codereview.appspot.com/26052
>>     
>
> Design question: should [('x', float), ('y', float)] and [('t',
> float), ('s', float)] hash to the same value or not?
>   

According to:

http://docs.python.org/reference/datamodel.html#object.__hash__

The only constraint is that a == b -> hash(a) == hash(b) (which is
broken currently in numpy, even for builtin dtypes). The main problem is
that I am not very clear yet on what a == b is for dtypes (the code for
PyArray_EquivTypes goes through PyObject_Compare for compound types). In
your example, both dtypes are not equal (and they do not hash the same).

cheers,

David


More information about the Numpy-discussion mailing list