Skip to content

Commit

Permalink
updated markdown to format code as python
Browse files Browse the repository at this point in the history
  • Loading branch information
jimy-byerley committed Mar 15, 2021
1 parent 66f431e commit f1565ca
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,36 @@ The elements must be extension-types (eg. class created in compiled modules) and

### basic usage:

```python
>>> from arrex import *
>>> a = typedlist([
myclass(...),
myclass(...),
], dtype=myclass)
>>> a[0]
myclass(...)
```

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

```python
>>> import typedlist.numpy # this is enabling numpy dtypes for arrex
>>> typedlist(dtype=np.float64)
```

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

```python
>>> import typedlist.glm # this is enabling glm dtypes for arrex
>>> typedlist(dtype=glm.vec4)
```


`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.

### Use it as a list:

```python
>>> a = typedlist(dtype=vec3)

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

>>> a.owner # the current data buffer
b'.........'
```

### Use it as a slice:

```python
>>> myslice = a[:5] # no data is copied
typedlist(....)
```

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

```python
>>> a = np.ones((6,3), dtype='f4')
>>> myslice = typedlist(a, dtype=vec3)
```

### buffer protocol

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

```python
>>> np.array(typedlist([....]))
```


## performances
Expand Down

0 comments on commit f1565ca

Please sign in to comment.