NumPy has dtypes (as I am sure everyone knows), but also DType classes. I.e that is the:
import numpy as np float64_dtype = np.dtype("float64") type(float64_dtype)
The is the DType class. Besides being referred to in some errors, the classes are not particularly interesting in most code, since we are used to
np.dtype("float64"), etc. although
StringDType(10) could e.g. be used to do
However, these classes are sensible objects and allow things like
isinstance checks. It has also always been a plan to implement abstract DType classes. For example we would have a
FloatingDType to represent any floating point number (float16, float32, float64, …), potentially even allowing
arr.astype(FloatingDType) (doesn’t actually exist yet).
There is enough use for this, that I would like to finally resolve where to put them and create the names. I have always rejected the main namespace, because it already has the scalar
np.int64, etc. and this is just not very common.
So, lets lets try if a poll can help give enough insight here to help make a decision.
np.types.<name>(might be used for more types)
- There must be a better way/place! (please comment)
Please don’t hesitate to add a comment!
More options (would prefer no double voting, since this wasn’t multiple choice ;).