added notes about numeric types
This commit is contained in:
parent
606965ce9f
commit
83f58e1da5
13
README.md
13
README.md
@ -58,13 +58,14 @@ class Foo(EnvExperiment):
|
|||||||
## Built-in Types
|
## Built-in Types
|
||||||
* Primitive types include:
|
* Primitive types include:
|
||||||
* `bool`
|
* `bool`
|
||||||
|
* `byte`
|
||||||
* `int32`
|
* `int32`
|
||||||
* `int64`
|
* `int64`
|
||||||
* `uint32`
|
* `uint32`
|
||||||
* `uint64`
|
* `uint64`
|
||||||
* `float`
|
* `float`
|
||||||
* `str` (note: fixed length, provide builtin methods?)
|
* `str` (note: fixed length, provide builtin methods?)
|
||||||
* `bytes`
|
* `bytes` (a list of `byte`, but with more convenient syntax)
|
||||||
* Collections include:
|
* Collections include:
|
||||||
* `list`: homogeneous (elements must be of the same type) fixed-size (no
|
* `list`: homogeneous (elements must be of the same type) fixed-size (no
|
||||||
append) list.
|
append) list.
|
||||||
@ -83,6 +84,16 @@ class Foo(EnvExperiment):
|
|||||||
```
|
```
|
||||||
* `range` (over numerical types)
|
* `range` (over numerical types)
|
||||||
|
|
||||||
|
### Numerical Types
|
||||||
|
* All binary operations expect the values to have the same type, no implicit
|
||||||
|
coercion would be performed, explicit casting is required.
|
||||||
|
* Casting can be done by `T(v)` where `T` is the target type, and `v` is the
|
||||||
|
original value. Examples: `int64(123)`
|
||||||
|
* Constant integers are treated as `int32` by default. If the value cannot
|
||||||
|
be stored in `int32`, `uint64` would be used if the integer is non-negative,
|
||||||
|
and `int64` would be used it the integer is negative.
|
||||||
|
* Only `uint32`, `int32` (and range of them) can be used as index.
|
||||||
|
|
||||||
## Generics
|
## Generics
|
||||||
We use [type variable](https://docs.python.org/3/library/typing.html#typing.TypeVar) for denoting generics.
|
We use [type variable](https://docs.python.org/3/library/typing.html#typing.TypeVar) for denoting generics.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user