Numpy ringbuffer at a fixed memory address to allow for significantly sped up numpy, sigpy, numba & pyFFTW calculations.
Project description
DvG_RingBuffer
Numpy ring buffer at a fixed memory address to allow for significantly sped up numpy, sigpy, numba & pyFFTW calculations.
- Based on:
https://pypi.org/project/numpy_ringbuffer/ by Eric Wieser.
DvG_RingBuffer can be used as a drop-in replacement for numpy_ringbuffer and provides several optimizations and extra features, but requires Python 3.
If, and only if the ring buffer is completely full, will it return its array data as a contiguous C-style numpy array at a single fixed memory address per ring buffer instance. It does so by unwrapping the discontiguous ring buffer array into a second extra unwrap buffer that is a private member of the ring buffer class. This is advantegeous for other accelerated computations by, e.g., numpy, sigpy, numba & pyFFTW, that benefit from being fed with contiguous arrays at the same memory address each time again, such that compiler optimizations and data planning are made possible.
When the ring buffer is not completely full, it will return its data as a contiguous C-style numpy array, but at different memory addresses. This is how the original numpy-buffer always operates.
Commonly, collections.deque() is used to act as a ring buffer. The benefits of a deque is that it is thread safe and fast (enough) for most situations. However, there is an overhead whenever the deque – a list-like container – needs to be transformed into a numpy array. Because DvG_RingBuffer already returns numpy arrays it will outperform a collections.deque() easily, tested to be a factor of ~60.
Methods
clear()
append()
appendleft()
extend()
extendleft()
pop()
popleft()
Properties
is_full
unwrap_address
current_address
dtype
shape
maxlen
Indexing & slicing
[] including negative indices and slicing
Changelog
1.0.0 (2020-06-29)
First release on PyPI
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dvg_ringbuffer-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35a86a6e68fe8a0708aad075dffac2ada9db7ea76a7e5ff22ac4d9ee63704544 |
|
MD5 | 2ac430bf66fe95851d9d4ef462bb147a |
|
BLAKE2b-256 | 5f730d8306c6918731e53d4a5790046b26bba44381e58bd64159511a84dc96d2 |