added builtin types section

pull/14/head
pca006132 2020-12-17 10:22:46 +08:00 committed by pca006132
parent 31c688b4c8
commit effe9434ab
1 changed files with 26 additions and 0 deletions

View File

@ -55,6 +55,32 @@ class Foo(EnvExperiment):
would not be kept across kernel calls, and that is a potential source of
confusion.
## Built-in Types
* Primitive types include:
* `bool`
* `int32`
* `int64`
* `float`
* `str` (note: fixed length, provide builtin methods?)
* `bytes`
* Collections include:
* `list`: homogeneous (elements must be of the same type) fixed-size (no
append) list.
* `tuple`: inhomogeneous fixed-size list, only pattern
matching (e.g. `a, b, c = (1, True, 1.2)`) and constant indexing
is supported:
```
t = (1, True)
# OK
a, b = t
# OK
a = t[0]
# Not OK
i = 0
a = t[i]
```
* `range` (over `int32`, `int64`, `float`)
## Generics
We use [type variable](https://docs.python.org/3/library/typing.html#typing.TypeVar) for denoting generics.