Skip to main content

This code has been transpiled from js-sparse-array and has minimal changes.

Usage

SparseArray implements MutableSequence.

We suggest you import the SparseArray as follows:

>>> from bitmap_sparse_array import SparseArray

Setting and getting

>>> sa = SparseArray()
>>> sa[1000000] = 'value'
>>> sa[1000000]
'value'
>>> sa[1]
IndexError()
>>> len(sa)
1000001

Iterating

Due to the sparse nature of SparseArray, it does not make sense to iterate over all values in the traditional sense because of possible omitted indices. Therefore, you cannot iterate over the SparseArray itself. Instead, 3 generators are provided.

>>> sa = SparseArray()
>>> sa[0] = '0'
>>> sa[2] = '2'

SparseArray.indices() returns a generator of indices that have values.

>>> list(sa.indices())
[0, 2]

SparseArray.items() returns a generator of tuples of indices and values, similar to Mapping.items().

>>> list(sa.items())
[(0, '0'), (2, '2')]

SparseArray.values(*, default=None, start=0, end=None) returns a generator of values with a default value for non-set indices.

>>> list(sa.values())
['0', None, '2']
>>> list(sa.values(default='default'))
['0', 'default', '2']

For the same reasons, you cannot get or set slices of a SparseArray, nor insert()

Metadata

Release files for bitmap-sparse-array 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bitmap-sparse-array 0.1.3
File Size Uploaded Provenance Actions
bitmap_sparse_array-0.1.3.tar.gz 5.8 kB Without provenance Details for bitmap_sparse_array-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bitmap-sparse-array 0.1.3
File Interpreter ABI Platform Actions
bitmap_sparse_array-0.1.3-py3-none-any.whl Python 3 none any Details for bitmap_sparse_array-0.1.3-py3-none-any.whl

Total release size: 10.2 kB

Release files / bitmap_sparse_array-0.1.3.tar.gz

Download URL bitmap_sparse_array-0.1.3.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bb4c94bd204bbef7dc417f4ed2aae2b3437fc75278e1b547619f2c5e63de996f
BLAKE2b-256 checksum
How to use checksums
804cd0ae233e1112dc983cb34d3a0944a418cdaa04c65f5cd98af602823c6bd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / bitmap_sparse_array-0.1.3-py3-none-any.whl

Download URL bitmap_sparse_array-0.1.3-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
646c566d551bac22b70f242ca167fe812db76805335adf6609f17a6fe6fcb35a
BLAKE2b-256 checksum
How to use checksums
dfed16911a2647053474d1dfb409d65bde606b30d8f2274243708fe2dafe6a49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for bitmap-sparse-array 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page