haydnv / tinychain

A next-gen database + SaaS framework for rapid development and integration of enterprise services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drop support for Python 3.8 and use generic types parameters for `Collection` schema, `Op` argument and return types, and `Map` and `Tuple`

haydnv opened this issue · comments

We should update the Python version declaration here: https://github.com/haydnv/tinychain/blob/main/client/setup.cfg

Support for generic types in Python 3.9 is documented here: https://peps.python.org/pep-0647/

When this issue is resolved, it should be possible to write e.g.:

import tinychain as tc
import typing

Batch = typing.TypeVar("Batch", bound=tc.UInt)

@tc.post
def matmul(l: tc.tensor.Tensor[Batch, 10], r: tc.tensor.Tensor[10, 5]) -> tc.tensor.Tensor[Batch, 5]:
    assert l.ndim == 2
    assert r.shape[1] == 5
    # ...

This also includes replacing Map.expect and Tuple.expect, and adding argument and return type parameters to each subclass of Op