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.3.tar.gz (7.2 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.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysparse-array-0.1.3.tar.gz
  • Upload date:
  • Size: 7.2 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.3.tar.gz
Algorithm Hash digest
SHA256 0b03c26ad82cf6610794adbe04ee7d32b7b59e7e33cfeb355f7ae912474a7fc5
MD5 e217f3f9fe41368c91cd98b36e769a53
BLAKE2b-256 766cc1d403f6fe8e89b839f7026b299ebd4f80cd006633454a732d8aeb3fa68d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysparse_array-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 705ed1c05cf8ff234be9a569437c58700200240370d5b5919f3f0a4b09ba2d25
MD5 f501dbf871db9486a1c3afb309a15c5b
BLAKE2b-256 f0d24c405cfbe1c6250a23e97abed7c4bdda4812a7c7fb468c3698342de48879

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