You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for returning lists, sets and homogeneous tuples from C (pyccel#2070)
Generalise `_extract_HomogeneousTupleType_FunctionDefResult` to
`_extract_HomogeneousContainerType_FunctionDefResult` to add support for
returning lists, sets and homogeneous tuples from C. Fixespyccel#1664 and
fixespyccel#1665
Improve docs
Copy file name to clipboardExpand all lines: docs/type_annotations.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,13 +41,33 @@ In general string type hints must be used to provide Pyccel with information abo
41
41
42
42
## Tuples
43
43
44
-
Currently Pyccel supports tuples used locally in functions and in certain cases as arguments, but not as returned objects or module variables. The implementation of the type annotations (including adding the missing support) is in progress. Currently homogeneous tuple type annotations are supported for local variables and function arguments (if the tuples contain scalar objects). Internally we handle homogeneous tuples as though they were NumPy arrays. When creating multiple dimensional tuples it is therefore important to ensure that all objects have compatible sizes otherwise they will be handled as inhomogeneous tuples.
44
+
Currently Pyccel supports tuples used locally in functions and in certain cases as arguments, but not as returned objects or module variables. The implementation of the type annotations (including adding the missing support) is in progress. Currently homogeneous tuple type annotations are supported for local variables and function arguments and results (if the tuples contain scalar objects). Internally we handle homogeneous tuples as though they were NumPy arrays. When creating multiple dimensional tuples it is therefore important to ensure that all objects have compatible sizes otherwise they will be handled as inhomogeneous tuples.
45
45
46
46
To declare a homogeneous tuple the syntax is as follows:
47
47
```python
48
48
a : tuple[int,...] = (1,2,3,4)
49
49
```
50
50
51
+
## Lists
52
+
53
+
Lists are in the process of being added to Pyccel. Homogeneous lists can be declared in Pyccel using the following syntax:
54
+
```python
55
+
a : list[int] = [1, 2]
56
+
b : list[bool] = [False, True]
57
+
c : list[float] = []
58
+
```
59
+
So far lists can be declared as local variables or as results of functions.
60
+
61
+
## Sets
62
+
63
+
Sets are in the process of being added to Pyccel. Homogeneous sets can be declared in Pyccel using the following syntax:
64
+
```python
65
+
a : set[int] = {1, 2}
66
+
b : set[bool] = {False, True}
67
+
c : set[float] = {}
68
+
```
69
+
So far sets can be declared as local variables or as results of functions.
70
+
51
71
## Dictionaries
52
72
53
73
Dictionaries are in the process of being added to Pyccel. They cannot yet be used effectively however the type annotations are already supported.
0 commit comments