Variadic protocols don't exist; many operations like stacking are inexpressible; the synatx is awful and verbose; etc. etc.
I've written more about this here as part of my TorchTyping project: [0]
[0] https://github.com/patrick-kidger/torchtyping/issues/37#issu...
I hope that these things could be solved with future iterations. For example:
Variadic protocols don't exist.
Hopefully they are added sometime. the syntax is awful and verbose.
Hopefully we can settle on allowing `1` instead of `Literal[1]` as a type (and other similar improvements). many operations like stacking are inexpressible.
These could be expressed if things like "multiplying"/"adding" literal numeric types would be supported.The variadic generics PEP was partly motivated by the ML use-case (and took input from maintainers of numpy ..etc), so I hope future iterations will also improve the usage in the ML space.
Pep was originally even longer and there's planned follow up peps for other tensor related type features like literal arithmetic to allow type hinting function like np.concatenate. I expect 2/3 more peps in that area in the next year or two.
The main case this PEP targets - concerns typing in numerical libraries.
However, despite the authors of the PEP working at facebook, the Pytorch team, at facebook, wasn't interested at all in the PEP. This is also from the PEP: For the sake of transparency - we also reached out to folks from a third popular numerical computing library, PyTorch, but did not receive a statement of endorsement from them. Our understanding is that although they are interested in some of the same issues - e.g. static shape inference - they are currently focusing on enabling this through a DSL rather than the Python type systemI agree that tracking array shapes at build time could catch certain classes of bugs (and I would love to have that capability). However, it's not as easy as it may seem. Consider the following example. It shows that even a simple slicing operation can change the number of array dimensions in ways that are only known at run time.
>>> def f(arr, elem):
... return arr[elem]
...
>>> arr=np.zeros((1, 1))
>>> f(arr, 0).shape
(1,)
>>> f(arr, ...).shape
(1, 1)
>>> f(arr, np.newaxis).shape
(1, 1, 1)The only issue now is that pytorch has their own "shapes" solution[0], and last I checked, were kinda reserved about participating in the standardization of variadic generics because they don't expect to use it.
I really really hope that the ML community comes together to use variadic generics because I believe it will save researchers and devs so many debug cycles (as well as compute resources, tbh).