Skip to main content

Wrapper for sharing numpy arrays between processes

Project description

np-shared-array

Utility for sharing numpy arrays between processes

Usage:

from src.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-0.0.1.tar.gz (3.1 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-0.0.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for np_shared_array-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dc3dc74a86a98e46407b27a73620248fb5de1581ad6fd5939a27c4b71662c280
MD5 ed6784d62ea5a34f1c8baba5e1ba713c
BLAKE2b-256 ec94492c40348de39e8223fc2954669b299840d2beebe7bfc76dd71f53467b13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for np_shared_array-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18ef0a9d9714f5c161e0581abf65dc64f22cce5a3886dd420ab11651cd9babbc
MD5 5bd72e73c2ef438a843fe608e9a8ac5b
BLAKE2b-256 feb9ab57cf1fda55f3efcbecef38c5e1b4946abfa4e44d87f46ecb86484c1efe

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