Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 646 – Variadic Generics #6

Closed
jorenham opened this issue Jun 2, 2022 · 1 comment
Closed

PEP 646 – Variadic Generics #6

jorenham opened this issue Jun 2, 2022 · 1 comment

Comments

@jorenham
Copy link

jorenham commented Jun 2, 2022

PEP 646 has been accepted for Python 3.11. The typing_extensions package provides an implementation for earlier Python versions.

At the time of writing, pyright fully supports this PEP, but mypy not just yet (python/mypy#12280)

The TypeVarTuple that this PEP introduces, could be used here to unify all separate e.g. Tensor1[T1], Tensor2[T1, T2], ... types into one Tensor[*T] type, significantly reducing the complexity of the array types in this package.

Are there any plans on implementing this at the moment?

@mrahtz
Copy link
Collaborator

mrahtz commented Jun 3, 2022

In short: no plans in the near future.

The longer version is that there are two key factors here:

  1. It looks like it's going to be a while before PEP 646 is widely supported. At the minimum, I think we'd want good support in both mypy and pytype. (pytype support is important because it's what we use at DeepMind.)
  2. Part of the reason we made TensorAnnotations was as a proof-of-concept, to provide evidence for the viability of PEP 646. Eventually, TensorAnnotations will hopefully not be needed, because the corresponding features will be part of libraries like TensorFlow and JAX themselves, using the features from PEP 646. So it might be the case that by the time PEP 646 is widely supported, some support for PEP 646-style annotations will already be present in the corresponding libraries.

I'll close this for now, but we might revisit this question depending on how things play out.

@mrahtz mrahtz closed this as completed Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants