Skip to content

Commit 80a8082

Browse files
committed
updated README.md
1 parent 59b516c commit 80a8082

File tree

1 file changed

+43
-33
lines changed

1 file changed

+43
-33
lines changed

Diff for: README.md

+43-33
Original file line numberDiff line numberDiff line change
@@ -73,39 +73,49 @@ print(loaded) # User(name="hello", Credentials(name="hello", password="world"))
7373

7474
### Supported types
7575

76-
> You can add additional types by importing them at the top of your file.
77-
> These types can reduce the output size.
78-
> ```python
79-
> from structurelib.types import *
80-
> ```
81-
> All additional types can be used without problem to replace the old ones and won't interfere with typechecking.
82-
> ```python
83-
> class MyClass:
84-
> attr: uint16
85-
> ```
86-
87-
| type | description | size | values |
88-
|-------------------|---------------------------|---------|--------------------------------------------------------|
89-
| int/integer | any integer | dynamic | -- +|
90-
| integer[n, False] | integer | n byte | 0 - 2<sup>8*n</sup> |
91-
| integer[n, True] | integer | n byte | -2<sup>8*(n-1)</sup> - 2<sup>8*(n-1)</sup> |
92-
| int8 | integer | 1 byte | -128 - 127 |
93-
| int16 | integer | 2 bytes | -32,768 - 32,767 |
94-
| int32 | integer | 4 bytes | -2,147,483,648 - 2,147,483,647 |
95-
| int64 | integer | 8 bytes | -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 |
96-
| uint | any positive integer | dynamic | 0 - +|
97-
| uint8 | positive integer | 1 byte | 0 - 255 |
98-
| uint16 | positive integer | 2 bytes | 0 - 65,535 |
99-
| uint32 | positive integer | 4 bytes | 0 - 4,294,967,295 |
100-
| uint64 | positive integer | 8 bytes | 0 - 18,446,744,073,709,551,615 |
101-
| float/floating | floating point number | 8 bytes | -1.7e308 - 1.7e308 |
102-
| float32 | floating point number | 4 bytes | -3.4e38 - 3.4e38 |
103-
| float64 | floating point number | 8 bytes | -1.7e308 - 1.7e308 |
104-
| str/string | text of any kind | dynamic | |
105-
| string[n] | text with length n | n bytes | |
106-
| bytes/binary | any binary data | dynamic | |
107-
| binary[n] | binary data with length n | n nyte | |
108-
| bool/boolean | boolean value | 1 byte | True/False |
76+
You can keep it basic and continue to use the builtin types and it should work
77+
78+
```python
79+
class MyStruct:
80+
name: str
81+
number: int
82+
```
83+
84+
But you can also add the additional types by importing them at the top of your file.
85+
These types can reduce the output size.
86+
```python
87+
from structurelib.types import *
88+
```
89+
All additional types can be used without problem to replace the old ones and won't interfere with typechecking.
90+
```python
91+
class MyStruct:
92+
name: string
93+
number: uint16
94+
```
95+
96+
| type | description | size | values |
97+
|-------------------|----------------------------|---------|--------------------------------------------------------|
98+
| int/integer | any integer | dynamic | -∞ - +∞ |
99+
| integer[n, False] | integer | n byte | 0 - 2<sup>8*n</sup> |
100+
| integer[n, True] | integer | n byte | -2<sup>8*(n-1)</sup> - 2<sup>8*(n-1)</sup> |
101+
| int8 | integer | 1 byte | -128 - 127 |
102+
| int16 | integer | 2 bytes | -32,768 - 32,767 |
103+
| int32 | integer | 4 bytes | -2,147,483,648 - 2,147,483,647 |
104+
| int64 | integer | 8 bytes | -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 |
105+
| uint | any positive integer | dynamic | 0 - +∞ |
106+
| uint8 | positive integer | 1 byte | 0 - 255 |
107+
| uint16 | positive integer | 2 bytes | 0 - 65,535 |
108+
| uint32 | positive integer | 4 bytes | 0 - 4,294,967,295 |
109+
| uint64 | positive integer | 8 bytes | 0 - 18,446,744,073,709,551,615 |
110+
| float/floating | floating point number | 8 bytes | -1.7e308 - 1.7e308 |
111+
| float32 | floating point number | 4 bytes | -3.4e38 - 3.4e38 |
112+
| float64 | floating point number | 8 bytes | -1.7e308 - 1.7e308 |
113+
| str/string | text of any kind | dynamic | |
114+
| string[n] | text with encoded length n | n bytes | |
115+
| char | single character | 1 byte | *0-255 |
116+
| bytes/binary | any binary data | dynamic | |
117+
| binary[n] | binary data with length n | n nyte | |
118+
| bool/boolean | boolean value | 1 byte | True/False |
109119

110120
Other builtin types like `list`, `dict`, `set` and so on are currently not supported.
111121

0 commit comments

Comments
 (0)