Skip to content

Commit b09a888

Browse files
committed
updated markdown to format code as python
1 parent f1565ca commit b09a888

File tree

1 file changed

+42
-43
lines changed

1 file changed

+42
-43
lines changed

README.md

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ The elements must be extension-types (eg. class created in compiled modules) and
88
### basic usage:
99

1010
```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(...)
1818
```
1919

2020
in that example, `myclass` can be a primitive numpy type, like `np.float64`
2121

2222
```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)
2525
```
2626

2727
it can be a more complex type, from module `pyglm` for instance
2828

2929
```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)
3232
```
3333

3434

@@ -37,44 +37,44 @@ it can be a more complex type, from module `pyglm` for instance
3737
### Use it as a list:
3838

3939
```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'.........'
5656
```
5757

5858
### Use it as a slice:
5959

6060
```python
61-
>>> myslice = a[:5] # no data is copied
62-
typedlist(....)
61+
>>> myslice = a[:5] # no data is copied
62+
typedlist(....)
6363
```
6464

6565
### Use it as a view on top of a random buffer
6666

6767
```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)
7070
```
7171

7272
### buffer protocol
7373

7474
It does support the buffer protocol, so it can be converted in a great variety of well known arrays, even without any copy
7575

7676
```python
77-
>>> np.array(typedlist([....]))
77+
>>> np.array(typedlist([....]))
7878
```
7979

8080

@@ -84,17 +84,16 @@ Time performances comparison between `list`, `numpy.ndarray`, and `arrex.typed
8484

8585
execution time (s) for 10k elements (dvec3)
8686

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+
9897

9998

10099
## Roadmap

0 commit comments

Comments
 (0)