Skip to main content

Memory mapped of datasets

Project description

Memmpy

Memmpy is a Python library for storing datasets in, and loading datasets from, memory mapped files. This is particularly useful for large datasets that do not fit in memory and therefore need to be processed in batches. Memmpy is based on the numpy.memmap implementation.

Who should use Memmpy?

Memmpy is primarily intended for use in medium to large scale machine learning applications in high energy particle physics, where the whole dataset would not fit into memory at once and iterating over the ROOT files is too slow. This could be because shuffling of datapoints is desired, or because only a fraction of the information or events is needed for training.

Memmpy is not intended for use in small applications where the entire dataset fits into memory and can be loaded at once. It is also not intended for use in very large applications where training is massively distributed.

Installation

Memmpy can be installed directly from PyPI using pip. It requires Python 3.10 or higher. If you want to process .root files, uproot is required. This can also be installed using pip.

pip install memmpy

Usage

A simple memory mapped file can be created as follows:

with WriteVector(path="data.mmpy", key="testdata") as memfile:
    # Append a single numpy array.
    # The shape and dtype will be inferred from the array.
    memfile.append(np.array([1, 2, 3]))
    
    # Append another numpy array of the same shape and dtype
    memfile.append(np.array([4, 5, 6]))

    # Extend the file by an array with an additional axis.
    memfile.extend(np.array([[7, 8, 9], [10, 11, 12]]))

memmap_data = read_vector(path="data.mmpy", key="testdata")

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

memmpy-0.1.5.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

memmpy-0.1.5-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file memmpy-0.1.5.tar.gz.

File metadata

  • Download URL: memmpy-0.1.5.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for memmpy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ff2afbf91b5902ee1eb4cd9aad5d599696b904d7e920f6f47a5eccb3ad076873
MD5 22b3eacb938045f5123c04dd2f5eb793
BLAKE2b-256 248261b59e10e4173a12242d252d94a91780ecf670024b4e776e4d0dba062d19

See more details on using hashes here.

File details

Details for the file memmpy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: memmpy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for memmpy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1bb97f9a637a81d6689b527f2b76064cde8b6eac0220dbcde41f403e21df5433
MD5 d7b5e2e3daa6f983d0ab759397b90ada
BLAKE2b-256 352b5e11807072271654f8f0e870f810706e0c8cc9879942f3fbb197da1c9f72

See more details on using hashes here.

Supported by

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