Skip to content

Commit f1565ca

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

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,36 @@ The elements must be extension-types (eg. class created in compiled modules) and
77

88
### basic usage:
99

10+
```python
1011
>>> from arrex import *
1112
>>> a = typedlist([
1213
myclass(...),
1314
myclass(...),
1415
], dtype=myclass)
1516
>>> a[0]
1617
myclass(...)
18+
```
1719

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

22+
```python
2023
>>> import typedlist.numpy # this is enabling numpy dtypes for arrex
2124
>>> typedlist(dtype=np.float64)
25+
```
2226

2327
it can be a more complex type, from module `pyglm` for instance
2428

29+
```python
2530
>>> import typedlist.glm # this is enabling glm dtypes for arrex
2631
>>> typedlist(dtype=glm.vec4)
32+
```
2733

2834

2935
`typedlist` is a dynamically sized, borrowing array, which mean the internal buffer of data is reallocated on insertion, but can be used to view and extract from any buffer.
3036

3137
### Use it as a list:
3238

39+
```python
3340
>>> a = typedlist(dtype=vec3)
3441

3542
# build from an iterable
@@ -46,22 +53,29 @@ it can be a more complex type, from module `pyglm` for instance
4653

4754
>>> a.owner # the current data buffer
4855
b'.........'
56+
```
4957

5058
### Use it as a slice:
5159

60+
```python
5261
>>> myslice = a[:5] # no data is copied
5362
typedlist(....)
63+
```
5464

5565
### Use it as a view on top of a random buffer
5666

67+
```python
5768
>>> a = np.ones((6,3), dtype='f4')
5869
>>> myslice = typedlist(a, dtype=vec3)
70+
```
5971

6072
### buffer protocol
6173

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

76+
```python
6477
>>> np.array(typedlist([....]))
78+
```
6579

6680

6781
## performances

0 commit comments

Comments
 (0)