
Hi,
As I am sure you are aware, Python 3.11 https://docs.python.org/3.11/whatsnew/3.11.html will ship with support for variadic generics (PEP 646 https://peps.python.org/pep-0646/). According to the PEP documentation, it will allow tensor shape type hints like this:
def to_gray(videos: Array[Time, Batch, Height, Width, Channels]): ...
I was wondering when, or if, Numpy plans to support these sort of type annotations. I did find some older discussion on github https://github.com/numpy/numpy/issues/16547 how you plan to annotate shape and dtypes of tensors, but I didn't manage to catch what is the current state of affairs concerning PEP 646.
For me personally, these type hints would really be a productivity boost to help catch syntax errors early. And perhaps more importantly, shape annotations will be much more reliable documentation than putting everything in a docstring.
I would love to hear Numpy's plans and considerations.
Thanks so much,
Hylke
P.s., I asked this question earlier on Stack Overflow https://stackoverflow.com/questions/73169372/support-for-tensor-type-hints-variadic-generics-in-numpy-pep-646, but I was suggested to take this question to this mailing list instead.
participants (1)
-
Hylke Donker