[Numpy-discussion] Re: dtype: hashing and cmp
Robert Kern
robert.kern at gmail.com
Sun May 28 12:35:01 EDT 2006
Simon Burton wrote:
> Is there a reason why dtype's are unhashable ? (ouch)
No one thought about it, probably. If you would like to submit a patch, I think
it we would check it in.
> On another point, is there a canonical list of dtype's ?
> I'd like to test the dtype of an array, and I always
> end up with something like this:
>
> if array.dtype == numpy.dtype('l'): ...
>
> When I would prefer to write something like:
>
> if array.dtype == numpy.Int32: ...
numpy.int32
There is a list on page 20 of _The Guide to NumPy_. It is included in the sample
chapters:
http://www.tramy.us/scipybooksample.pdf
> (i can never remember these char codes !)
>
> Alternatively, should dtype's __cmp__ promote the other arg
> to a dtype before the compare ?
> I guess not, since that would break a lot of code: eg. dtype(None)
> is legal.
Correct, it should not.
--
Robert Kern
"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
mailing list