@@ -8,27 +8,27 @@ The elements must be extension-types (eg. class created in compiled modules) and
8
8
### basic usage:
9
9
10
10
``` python
11
- >> > from arrex import *
12
- >> > a = typedlist([
13
- myclass(... ),
14
- myclass(... ),
15
- ], dtype = myclass)
16
- >> > a[0 ]
17
- myclass(... )
11
+ >> > from arrex import *
12
+ >> > a = typedlist([
13
+ myclass(... ),
14
+ myclass(... ),
15
+ ], dtype = myclass)
16
+ >> > a[0 ]
17
+ myclass(... )
18
18
```
19
19
20
20
in that example, ` myclass ` can be a primitive numpy type, like ` np.float64 `
21
21
22
22
``` python
23
- >> > import typedlist.numpy # this is enabling numpy dtypes for arrex
24
- >> > typedlist(dtype = np.float64)
23
+ >> > import typedlist.numpy # this is enabling numpy dtypes for arrex
24
+ >> > typedlist(dtype = np.float64)
25
25
```
26
26
27
27
it can be a more complex type, from module ` pyglm ` for instance
28
28
29
29
``` python
30
- >> > import typedlist.glm # this is enabling glm dtypes for arrex
31
- >> > typedlist(dtype = glm.vec4)
30
+ >> > import typedlist.glm # this is enabling glm dtypes for arrex
31
+ >> > typedlist(dtype = glm.vec4)
32
32
```
33
33
34
34
@@ -37,44 +37,44 @@ it can be a more complex type, from module `pyglm` for instance
37
37
### Use it as a list:
38
38
39
39
``` python
40
- >> > a = typedlist(dtype = vec3)
41
-
42
- # build from an iterable
43
- >> > a = typedlist([], dtype = vec3)
44
-
45
- # append some data
46
- >> > a.append(vec3(1 ,2 ,3 ))
47
-
48
- # extend with an iterable
49
- >> > a.extend(vec3(i) for i in range (5 ))
50
-
51
- >> > len (a) # the current number of elements
52
- 6
53
-
54
- >> > a.owner # the current data buffer
55
- b ' .........'
40
+ >> > a = typedlist(dtype = vec3)
41
+
42
+ # build from an iterable
43
+ >> > a = typedlist([], dtype = vec3)
44
+
45
+ # append some data
46
+ >> > a.append(vec3(1 ,2 ,3 ))
47
+
48
+ # extend with an iterable
49
+ >> > a.extend(vec3(i) for i in range (5 ))
50
+
51
+ >> > len (a) # the current number of elements
52
+ 6
53
+
54
+ >> > a.owner # the current data buffer
55
+ b ' .........'
56
56
```
57
57
58
58
### Use it as a slice:
59
59
60
60
``` python
61
- >> > myslice = a[:5 ] # no data is copied
62
- typedlist(... .)
61
+ >> > myslice = a[:5 ] # no data is copied
62
+ typedlist(... .)
63
63
```
64
64
65
65
### Use it as a view on top of a random buffer
66
66
67
67
``` python
68
- >> > a = np.ones((6 ,3 ), dtype = ' f4' )
69
- >> > myslice = typedlist(a, dtype = vec3)
68
+ >> > a = np.ones((6 ,3 ), dtype = ' f4' )
69
+ >> > myslice = typedlist(a, dtype = vec3)
70
70
```
71
71
72
72
### buffer protocol
73
73
74
74
It does support the buffer protocol, so it can be converted in a great variety of well known arrays, even without any copy
75
75
76
76
``` python
77
- >> > np.array(typedlist([... .]))
77
+ >> > np.array(typedlist([... .]))
78
78
```
79
79
80
80
@@ -84,17 +84,16 @@ Time performances comparison between `list`, `numpy.ndarray`, and `arrex.typed
84
84
85
85
execution time (s) for 10k elements (dvec3)
86
86
87
- ```
88
- set item
89
- list: 2.31e-03
90
- numpy: 8.29e-03
91
- arrex: 2.29e-03 (3x faster then numpy)
92
-
93
- get item
94
- list: 5.47e-04
95
- numpy: 1.54e-03
96
- arrex: 7.47e-04 (2x faster than numpy)
97
- ```
87
+ set item
88
+ list: 2.31e-03
89
+ numpy: 8.29e-03
90
+ arrex: 2.29e-03 (3x faster then numpy)
91
+
92
+ get item
93
+ list: 5.47e-04
94
+ numpy: 1.54e-03
95
+ arrex: 7.47e-04 (2x faster than numpy)
96
+
98
97
99
98
100
99
## Roadmap
0 commit comments