Skip to main content

Python Version PyPI version License: MIT

ArrayFIFO

A FIFO buffer (queue) for efficient sharing of numpy arrays between multiple processes. Faster than multiprocessing.Queue because it uses shared memeory as a ring buffer, rather than pickling data and sending it over slow pipes.

Inspired by ArrayQueues. ArrayFIFO uses locks to support more than one producer and comsumer process, and it supports arrays whose shape and dtype can change arbitrarily with every put call.

Usage example

import numpy as np
from multiprocessing import Process
from arrayfifo import ArrayFIFO

def produce(queue):
    for i in range(20):
        random_shape = np.random.randint(5,10, size=3)
        array = np.random.randn(*random_shape)
        queue.put(array, meta=i)
        print(f'produced {type(array)} {array.shape} {array.dtype}; meta: {i}; hash: {hash(array.tobytes())}\n')

def consume(queue, pid):
    while True:
        array, meta = queue.get()
        print(f'consumer {pid} consumed {type(array)} {array.shape} {array.dtype}; meta: {meta}; hash: {hash(array.tobytes())}\n')

queue = ArrayFIFO(bytes=10e6)
producer = Process(target=produce, args=(queue,))
consumers = [Process(target=consume, args=(queue, pid)) for pid in range(3)]
for c in consumers:
    c.start()
producer.start()

Metadata

Release files for arrayfifo 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arrayfifo 0.0.3
File Size Uploaded
arrayfifo-0.0.3.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arrayfifo 0.0.3
File Interpreter ABI Platform
arrayfifo-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 kB

Release files / arrayfifo-0.0.3.tar.gz

Download URL arrayfifo-0.0.3.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7159ce546c05e85f8c15637a2789cbfbe1fc25307a463666e4f9d5e1f0995e7c
BLAKE2b-256 checksum
How to use checksums
95caabf98dc8d0b4f95f9b7c668b3a9b6e9ff4d7b1a59772ec456afca832e663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / arrayfifo-0.0.3-py3-none-any.whl

Download URL arrayfifo-0.0.3-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
916b2644805b94b676d26dcf98a449a17f338685150dd5b5f327d14a4265637e
BLAKE2b-256 checksum
How to use checksums
e361dc57a5460a7ed5c3698b3841c61d973e900c236ea193d72871c767dfa57c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page