Skip to main content

Wrapper for sharing numpy arrays between processes

Project description

np-shared-array

Utility for sharing numpy arrays between processes. This can be useful if you have a background process performing a calculation and main process on an API which can query the array.

Usage:

from np_shared_array import create_shared_array, SharedNumpyArray
from multiprocessing import Process


def worker(shared_array: SharedNumpyArray):
    array = shared_array.to_numpy()
    with shared_array.lock:
        array[0][0] = 1


def main():
    shape = [10, 10]
    shared_array = create_shared_array(shape)
    array = shared_array.to_numpy()
    p = Process(
        target=worker,
        args=(shared_array,)
    )
    p.start()
    p.join()
    with shared_array.lock:
        print(array[0][0])


if __name__ == "__main__":
    main()

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

np_shared_array-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

np_shared_array-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file np_shared_array-1.0.0.tar.gz.

File metadata

  • Download URL: np_shared_array-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for np_shared_array-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4b6e44eb2d14378425d9bcc39d17b5fcfd646132c24d677c6cc86bad1e288e1f
MD5 4b8b3591b4597bd706218c9aed085b4f
BLAKE2b-256 0976c571217a6257dd3348f9d7f6eb00f0a7a961d93d253c9a72ab506ec66f1b

See more details on using hashes here.

File details

Details for the file np_shared_array-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for np_shared_array-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd4c89b6c260a21e2988602e6ec887dac6e528a2b2f95c6d9b71ad063848f81e
MD5 35533421a48e40064ab9c4ce2b50cc10
BLAKE2b-256 77c8ab232d93dd788ba2b34b09f8b69db83d443d586caffcc4215e26bcd9fdb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page