[Numpy-discussion] Implementing hashing protocol for dtypes
Wed Mar 11 23:00:24 CDT 2009
On Wed, Mar 11, 2009 at 22:49, David Cournapeau <firstname.lastname@example.org> wrote:
> On Thu, Mar 12, 2009 at 5:36 AM, Robert Kern <email@example.com> wrote:
>> On Wed, Mar 11, 2009 at 15:06, David Cournapeau <firstname.lastname@example.org> wrote:
>>> I was looking at #936, to implement correctly the hashing protocol for
>>> dtypes. Am I right to believe that tp_hash should recursively descend
>>> fields for compound dtypes, and the hash value should depend on the
>>> size/ndim/typenum/byteorder for each "atomic" dtype + fields name (and
>>> titles) ? Contrary to comparison, we can't reuse the python C api,
>>> since PyObject_Hash cannot be applied to the fields dict, right ?
>> Usually, one constructs a hashable analogue; e.g. taking the .descr
>> and converting all of the lists to tuples. Then use PyObject_Hash on
> Is the .descr of two dtypes guaranteed to be equal whenever the dtypes
> are equal ? It is not obvious to me that PyArray_EquivTypes is
> equivalent to comparing the descr ?
It was an example.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion