forked from M-Labs/artiq
pyon: complex types
This commit is contained in:
parent
86681dccff
commit
22946a0c2f
|
@ -5,7 +5,7 @@ objects. Its main features are:
|
||||||
* Human-readable format compatible with the Python syntax.
|
* Human-readable format compatible with the Python syntax.
|
||||||
* Each object is serialized on a single line, with only ASCII characters.
|
* Each object is serialized on a single line, with only ASCII characters.
|
||||||
* Supports all basic Python data structures: None, booleans, integers,
|
* Supports all basic Python data structures: None, booleans, integers,
|
||||||
floats, strings, tuples, lists, dictionaries.
|
floats, complex numbers, strings, tuples, lists, dictionaries.
|
||||||
* Those data types are accurately reconstructed (unlike JSON where e.g. tuples
|
* Those data types are accurately reconstructed (unlike JSON where e.g. tuples
|
||||||
become lists, and dictionary keys are turned into strings).
|
become lists, and dictionary keys are turned into strings).
|
||||||
* Supports Numpy arrays.
|
* Supports Numpy arrays.
|
||||||
|
@ -33,6 +33,7 @@ _encode_map = {
|
||||||
bool: "bool",
|
bool: "bool",
|
||||||
int: "number",
|
int: "number",
|
||||||
float: "number",
|
float: "number",
|
||||||
|
complex: "number",
|
||||||
str: "str",
|
str: "str",
|
||||||
bytes: "bytes",
|
bytes: "bytes",
|
||||||
tuple: "tuple",
|
tuple: "tuple",
|
||||||
|
@ -46,8 +47,10 @@ _encode_map = {
|
||||||
}
|
}
|
||||||
|
|
||||||
_numpy_scalar = {
|
_numpy_scalar = {
|
||||||
"int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64",
|
"int8", "int16", "int32", "int64",
|
||||||
"float16", "float32", "float64"
|
"uint8", "uint16", "uint32", "uint64",
|
||||||
|
"float16", "float32", "float64", "float128",
|
||||||
|
"complex64", "complex128", "complex256",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,6 +189,7 @@ _eval_dict = {
|
||||||
"npscalar": _npscalar
|
"npscalar": _npscalar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def decode(s):
|
def decode(s):
|
||||||
"""Parses a string in the Python syntax, reconstructs the corresponding
|
"""Parses a string in the Python syntax, reconstructs the corresponding
|
||||||
object, and returns it."""
|
object, and returns it."""
|
||||||
|
|
Loading…
Reference in New Issue