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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysparse-array-0.1.1.tar.gz
  • Upload date:
  • Size: 3.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.1.tar.gz
Algorithm Hash digest
SHA256 6b7aea73a7bb7fa83e798dda0cc5218e86561ec8553b9b620cd0885ce0c5b9e0
MD5 aa266bd4c5371bbd84cac7021bbb8f5c
BLAKE2b-256 f4fb07dfee090cdbbe4567044a0f30d3954017aaa4980465c8a48a3ed51f646d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysparse_array-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01f4a206d291674b3388e82e13908ff598bbec45ec4a465ba94f9a5730902a69
MD5 d271036ec5e58069274e731aaed2fbbc
BLAKE2b-256 e6fcb54b940f802a0a0ea15fa09460ec11e1dc2141f27e87c092278022608949

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