patrick-kidger / patrick-kidger/jaxtyping

Why not `TypeVarTuple`?

Open
#5 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
1.9k
Forks
96
PR merge metrics
No merged PRs in 30d

Description

TypeVarTuple is about to be introduced in Python 3.11, but it's already usable with typing_extensions.

Docs: https://docs.python.org/3.11/library/typing.html#typing.TypeVarTuple

Example:

from typing import Generic, Literal, TypeVar
from typing_extensions import TypeVarTuple, Unpack

dims = TypeVarTuple("dims")
dtype = TypeVar("dtype")
dim1 = Literal["dim1"]
dim2 = Literal["dim2"]
dim3 = Literal["dim3"]
batch = Literal["batch"]
c1 = Literal["c1"]
c2 = Literal["c2"]

class f32(Generic[Unpack[dims]]): ...
class PyTree(Generic[dtype]): ...

def matrix_multiply(x: f32[dim1, dim2], y: f32[dim2, dim3]) -> f32[dim1, dim3]:
    ...

def accepts_pytree_of_ints(x: PyTree[int]):
    ...

def accepts_pytree_of_arrays(x: PyTree[f32[batch, None, c2]]):
    ...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files or tests. Start by reviewing the project's current typing support against Python 3.11's TypeVarTuple documentation and the typing_extensions examples; done would require a decided scope and support for the examples shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.