transonic.typing
Create Pythran signatures from type hints
User API
- class transonic.typing.Type(*args, name_calling_module=None)[source]
Bases:
TemplateVar
,FusedType
Template variable representing the dtype of an array.
As a user, it is useful only for fused types.
>>> Type(int, float) Type(int, float)
- class transonic.typing.NDim(*args, shift=0, name_calling_module=None)[source]
Bases:
TemplateVar
Template variable representing the number of dimension of an array.
As a user, it is useful only for fused types.
>>> N = NDim(1, 2) >>> N1 = N + 1
- class transonic.typing.Array(*args, **kwargs)[source]
Bases:
object
Represent a Numpy array.
>>> Array[int, "2d"] Array[int, "2d"]
>>> Array[int, "2d", "C"] Array[int, "2d", "C"]
>>> Array[int, "2d", "F"] Array[int, "2d", "F"]
>>> Array[int, "2d", "strided"] Array[int, "2d", "strided"]
Fused types:
>>> Array[Type(int, float), "1d"] Array[Type(int, float), "1d"]
>>> Array[float, NDim(2, 3)] Array[float, NDim(2, 3)]
>>> Array[int, "1d", "C", "positive_indices"] Array[int, "1d", "C", "positive_indices"]
- class transonic.typing.List(*args, **kwargs)[source]
Bases:
object
Similar to typing.List
>>> List[List[int]] List[List[int]]
- class transonic.typing.Tuple(*args, **kwargs)[source]
Bases:
object
Similar to typing.Tuple
>>> Tuple[int, Array[int, "2d"]] Tuple[int, Array[int, "2d"]]
- class transonic.typing.Dict(*args, **kwargs)[source]
Bases:
object
Similar to typing.Dict
>>> Dict[str, int] Dict[str, int]
- class transonic.typing.Set(*args, **kwargs)[source]
Bases:
object
Similar to typing.Set
>>> Set[str] Set[str]
- class transonic.typing.Union(*args, **kwargs)[source]
Bases:
object
Similar to typing.Union
>>> Union[float, Array[int, "1d"]] Union[float, Array[int, "1d"]]
- transonic.typing.str2type(str_type)[source]
Compute a Transonic type from a string
>>> str2type("int[:,:]") Array[int, "2d"]
>>> str2type("int or float[]") Union[int, Array[float, "1d"]]
>>> str2type("(int, float[:, :])") Tuple[int, Array[float, "2d"]]
Internal API
- class transonic.typing.TemplateVar(*args, name_calling_module=None)[source]
Bases:
object
Base class for template variables
>>> T = TemplateVar("T") >>> T = TemplateVar("T", int, float)
>>> T = TemplateVar() Traceback (most recent call last): ... ValueError
>>> T = TemplateVar(1) Traceback (most recent call last): ... TypeError: (1,) [False]
Functions
|
Declare a type as constant ( |
|
Format a Transonic type as a backend (Pythran, Cython, ...) type |
|
|
|
|
|
Compute a Transonic type from a string |
|
Compute the Transonic type corresponding to a Python object |
Classes
|
Represent a Numpy array. |
Metaclass for the Array class |
|
|
Private API class for const |
|
Similar to typing.Dict |
Metaclass for the Dict class |
|
|
|
|
Similar to typing.List |
Metaclass for the List class |
|
|
An enumeration. |
|
Type of the Transonic types (used to create metaclasses) |
|
Template variable representing the number of dimension of an array. |
|
Similar to typing.Optional |
|
|
|
Similar to typing.Set |
|
Metaclass for the Set class |
|
Base class for template variables |
|
Similar to typing.Tuple |
|
Metaclass for the Tuple class |
|
Template variable representing the dtype of an array. |
|
Similar to typing.Union |
|
Metaclass for the Union class |
|
TemplateVar used for the Union type |