[Numpy-discussion] Feelings about type aliases in NumPy

Joshua Wilson josh.craig.wilson at gmail.com
Fri Apr 24 11:45:17 EDT 2020


Hey everyone,

Over in numpy-stubs we've been working on typing "array like":

https://github.com/numpy/numpy-stubs/pull/66

It would be nice if the type were public so that downstream projects
could use it (e.g. it would be very helpful in SciPy). Originally the
plan was to only make it publicly available at typing time and not
runtime, which would mean that no changes to NumPy are necessary; see

https://github.com/numpy/numpy-stubs/pull/66#issuecomment-618784833

for more information on how that works.

But, Stephan pointed out that it might be confusing to users for
objects to only exist at typing time, so we came around to the
question of whether people are open to the idea of including the type
aliases in NumPy itself. Ralf's concrete proposal was to make a module
numpy.types (or maybe numpy.typing) to hold the aliases so that they
don't pollute the top-level namespace. The module would initially
contain the types

- ArrayLike
- DtypeLike
- (maybe) ShapeLike

Note that we would not need to make changes to NumPy right away;
instead it would probably be done when numpy-stubs is merged into
NumPy itself.

What do people think?

- Josh


More information about the NumPy-Discussion mailing list