[Numpy-discussion] type and kind for custom dtypes
alex at alexsamuel.net
Mon May 6 09:46:50 EDT 2019
Thanks very much for looking into this!
> The reason is that when the "kind" and "itemsize" and "byte order" are
> identical, the numpy code decides that data types can be cast (because
> they are equivalent). So basically, the "kind" must not be equal unless
> the "type"/dtype only differs in precision or similar.
> (The relevant code is in multiarraymodule.c in PyArray_EquivTypes)
That makes sense, and explains why the cast-less coercion takes place for some type pairs and not for others.
> Frankly, I do not think there is any, because nobody ever created many
> types (there is only quaternions and rationals publicly available).
OK. I'm a bit surprised to hear this, as the API for adding dtypes is actually rather straightforward!
For now, then, I will stick with my current scheme of assigning successive kind values to my dtypes, and hope for the best when running with other extension dtypes (which, it seems, may be unlikely).
More information about the NumPy-Discussion