Greetings! Could np.object_ be made generic? For example, if I have an object array of two-element integer tuples, it would be ideal if I could type hint the array with np.dtype[np.object_[tuple[int, int]]]; this would allow us to distinguish between object arrays by their contained types. (I.e., np.dtype[np.object_[tuple[int, int]]] is not the same as np.dtype[np.object_[datetime.date]].)
Context: I am the lead developer of StaticFrame (https://github.com/static-frame/static-frame), an alternative DataFrame library built on an immutable data model. StaticFrame has recently made DataFrames (and other containers) generic (https://towardsdatascience.com/type-hinting-dataframes-for-static-analysis-and-runtime-validation-3dedd2df481d). When specifying columnar types, we use NumPy generic types. While this provides a great deal of flexibility for most types, when an object array is involved, we cannot express anything about what is contained in the object array. Making np.object_ generic would solve this issue. I am happy to create an issue and explore a PR if this seems like a good enhancement. _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com