All Projects → portugueslab → arrayqueues

portugueslab / arrayqueues

Licence: MIT license
Multiprocessing queues for numpy arrays using shared memory

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to arrayqueues

cottoncandy
sugar for s3
Stars: ✭ 33 (-23.26%)
Mutual labels:  numpy-arrays
Py
Repository to store sample python programs for python learning
Stars: ✭ 4,154 (+9560.47%)
Mutual labels:  numpy-arrays
tiler
N-dimensional NumPy array tiling and merging with overlapping, padding and tapering
Stars: ✭ 26 (-39.53%)
Mutual labels:  numpy-arrays
python-intro-to-numpy
Cheat Sheet generated in the Introduction to NumPy course
Stars: ✭ 30 (-30.23%)
Mutual labels:  numpy-arrays
Xtensor.jl
Julia package for xtensor-julia
Stars: ✭ 38 (-11.63%)
Mutual labels:  numpy-arrays

ArrayQueues

Python Version Tests Coverage Status Code style: black License: MIT PyPI version

This package provides a drop-in replacement for the Python multiprocessing Queue class which handles transport of large numpy arrays. It avoids pickling and uses the multiprocessing Array class in the background. The major difference between this implementation and the normal queue is that the maximal amount of memory that the queue can have must be specified beforehand.

Attempting to send an array of a different shape or datatype of the previously inserted one resets the queue. Only passing of numpy arrays is supported, optionally annotated with timestamps if using the TimestampedArrayQueue class, but other object types can be supported by extending the class.

The package has been tested on Python 3.6/3/7 on Windows and MacOS and Linux with Travis. Python 2.7 is not supported.

Usage example

from arrayqueues.shared_arrays import ArrayQueue
from multiprocessing import Process
import numpy as np

class ReadProcess(Process):
    def __init__(self, source_queue):
        super().__init__()
        self.source_queue = source_queue
      
    def run(self):
        print(self.source_queue.get())

if __name__ == "__main__":
    q = ArrayQueue(1) # intitialises an ArrayQueue which can hold 1MB of data
    n = np.full((5,5), 5)
    q.put(n)
    r = ReadProcess(q)
    r.start()
    r.join()
    

Further examples can be found in tests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].