Skip to main content

A package that enables on-the-fly encoding and decoding of large NumPy arrays as Sparse binaries.

Project description

This package exists for one purpose: to encode and decode sparse numpy arrays into a more space-efficient format. Its target audience is users requiring rapid access to massive arrays without memory issues.

Ordinarily, a numpy array might be stored in one of a couple of ways:

  1. As a binary
  2. As a compressed file format (e.g., h5df)

The advantage of binary is that the file can be memory mapped, allowing access to sections of the array without out-of-memory (OOM) issues. The disadvantage is that such binaries are, necessarily, of a very large file size.

The advantage of compressed file formats is that they provide a much smaller disk space footprint, but at the cost of slower file access. Even h5df file formats, which can provide memory-mapped services of their own, will still be necessarily slow because the non-contiguous array has to be searched to find the relevant indices.

PySparse takes a given numpy array, and encodes it into two (smaller) arrays - a 1D array containing the non-zero values, and a 2D array containing the mapped coordinates for these values in the original 'dense' numpy array.

The resultant arrays can then be re-loaded into the SparseArray class, from which indexing can be performed to return to the original dense array.

SparseArray is NOT a child class of Numpy, and numpy functions cannot be performed directly on it (for now). To do this, you would need to manually implement a solution yourself e.g., decoding the entire array at once using [:], or using a for-loop to iterate through the SparseArray in chunks to avoid OOM errors.

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

pysparse-array-0.1.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

pysparse_array-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pysparse-array-0.1.2.tar.gz.

File metadata

  • Download URL: pysparse-array-0.1.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for pysparse-array-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f835631dcbbe972769b4e4cc0deebd98f487be7b68699e01a616c76b00d489d8
MD5 c73256674b796f4263b624df6f1a356b
BLAKE2b-256 b72b31f28e406b719a64e8d81472f920d546e0f66e11c7c192ec9f448534dffe

See more details on using hashes here.

File details

Details for the file pysparse_array-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pysparse_array-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for pysparse_array-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 370c9aa35d3bb1ef97fb7ebb4b1485c65b32a0417083ece5d38879a9f451f891
MD5 0d82e56a84d99cc1bf5571cc605300b0
BLAKE2b-256 4e73355fa2b8cff555061f8a8cb0f7aa4ac34d7d7f42f2e22d006620d6e4bd88

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