[Numpy-discussion] Type annotations for NumPy
Stephan Hoyer
shoyer at gmail.com
Sun Nov 26 13:58:55 EST 2017
On Sat, Nov 25, 2017 at 3:34 PM Matthew Rocklin <mrocklin at gmail.com> wrote:
> Thoughts on basing this on a more generic Array type rather than the
> np.ndarray? I can imagine other nd-array libraries (XArray, Tensorflow,
> Dask.array) wanting to reuse this work. For dask.array in particular we
> would want to copy this entirely, but we probably can't specify that
> dask.arrays are np.ndarrays. It would be nice to ensure that the container
> type was swappable.
>
Yes, absolutely. I do briefly mention this in my longer doc (see the
"Syntax" section). This is also one of my personal goals for this project.
This will be most relevant when we start working on typing support for
array shapes and broadcasting: details like data types can be more library
specific, and can probably be expressed with the existing generics system
in the typing module.
After we do some experimentation to figure out appropriate syntax and
semantics for array shape typing, I would like to standardize the rules for
typing multi-dimensional arrays in Python. This will probably entail
writing a PEP, so we can add appropriate base classes in the typing module.
I view this as the natural complement to existing standard library features
that make it easier to interchange between multiple multi-dimensional array
libraries, such as memory views and the buffer protocol.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20171126/937d2698/attachment.html>
More information about the NumPy-Discussion
mailing list