NumPy dtype API improvement suggestion

I am interested in suggesting an API improvement for NumPy. I wish to make it so that the following code: @np.dtype class Point: x: np.int16 y: np.int16 would be equivalent to the following code: Point = np.dtype([('x', np.int16), ('y', np.int16)]) I am willing to submit the code changes required to make this happen.

On Sun, 2020-07-26 at 17:31 +0100, Kevin Sheppard wrote:
I agree with this type of use case (whatever the syntax is). But I think there are too many small issues around it currently to do that in NumPy. For that the new DTypes need to move along a bit further, so that we do not lock-in nice syntax with features that have lots of quirks. See also: https://numpy.org/neps/nep-0041-improved-dtype-support.html https://numpy.org/neps/nep-0042-new-dtypes.html I think you could do much of such syntax now, but I would suggest to do it outside of NumPy proper (at least the experimentation) at this time for that reason. Hopefully, it won't be too long until we can think of creating such API for good inside NumPy. Cheers, Sebastian

On Sun, 2020-07-26 at 17:31 +0100, Kevin Sheppard wrote:
I agree with this type of use case (whatever the syntax is). But I think there are too many small issues around it currently to do that in NumPy. For that the new DTypes need to move along a bit further, so that we do not lock-in nice syntax with features that have lots of quirks. See also: https://numpy.org/neps/nep-0041-improved-dtype-support.html https://numpy.org/neps/nep-0042-new-dtypes.html I think you could do much of such syntax now, but I would suggest to do it outside of NumPy proper (at least the experimentation) at this time for that reason. Hopefully, it won't be too long until we can think of creating such API for good inside NumPy. Cheers, Sebastian
participants (4)
-
Eyal Kutz
-
Feng Yu
-
Kevin Sheppard
-
Sebastian Berg