[Numpy-discussion] dtype: hashing and cmp

Simon Burton simon at arrowtheory.com
Sun May 28 00:51:00 EDT 2006


Is there a reason why dtype's are unhashable ? (ouch)

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: ...

(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.

Simon.

-- 
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com 




More information about the NumPy-Discussion mailing list