Skip to main content

image image image image build image CodeQL CodSpeed Badge image ty

Sparse vectors optimized for memory and NumPy integrations.

numpy handles densely populated n-dimemsional arrays. scipy.sparse handles sparsely populated 2-dimensional arrays, i.e., matrices. What's missing from the ecosystem is sparsely populated 1-dimensional arrays, i.e., vectors.

NumPy Python Spector
1-dim bool numpy.array set[int] spector.indices
1-dim float numpy.array dict[int, float] spector.vector
scipy.sparse.dok_matrix dict[int, dict[int, float]] spector.matrix

Indices and vectors are implemented in Cython as hash sets and maps. All native operations are optimized and release the GIL. Objects are safe for concurrent reads across threads; writers must not overlap readers or other writers on the same object.

  • conversion between sparse numpy arrays
  • conversion between dense numpy arrays
  • binary set operations
  • binary math operations
  • map, filter, and reduce operations with numpy universal functions

Usage

indices

A sparse boolean array with a set interface.

>>> from spector import indices
>>> ind = indices([0, 2])
>>> ind
indices([2 0])
>>> 1 in ind
False
>>> ind.add(1)
True
>>> ind.todense()
array([ True,  True,  True])
>>> ind.fromdense(_)
indices([2 1 0])

vector

A sparse float array with a mapping interface.

>>> from spector import vector
>>> vec = vector({0: 1.0, 2: 2.0, 4: 1.0})
>>> vec
vector([4 2 0], [1. 2. 1.])
>>> vec[2] += 1.0
>>> vec[2]
3.0
>>> vec.todense()
array([1., 0., 3., 0., 1.])
>>> vector.fromdense(_)
vector([4 2 0], [1. 3. 1.])
>>> vec.sum()
5.0
>>> vec + vec
vector([0 2 4], [2. 6. 2.])

Vectors support math operations with scalars, and with vectors if the set method is unambiguous.

vector operation set method ufunc
+ union add
* intersection multiply
- subtract
/ true_divide
** power
| union max
& intersection min
^ symmetric_difference
difference difference

matrix

A mapping of keys to vectors.

>>> from spector import matrix
>>> mat = matrix({0: {1: 2.0}})
>>> mat
matrix(<class 'spector.vector.vector'>, {0: vector([1], [2.])})
>>> mat.row, mat.col, mat.data
(array([0]), array([1]), array([2.]))

Installation

pip install spector

Tests

100% branch coverage.

pytest [--cov]

Metadata

Release files for spector 1.7

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

Source distribution (sdist)

Source distribution for spector 1.7
File Size Uploaded Provenance
spector-1.7.tar.gz 262.8 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for spector 1.7
File
spector-1.7-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
spector-1.7-cp311-abi3-win32.whl CPython 3.11 abi3 Windows x86-32 Details
spector-1.7-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
spector-1.7-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
spector-1.7-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
spector-1.7-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
spector-1.7-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
spector-1.7-cp311-abi3-macosx_10_9_x86_64.whl CPython 3.11 abi3 macOS 10.9+ x86-64 Details

Total release size: 10.1 MB

Release files / spector-1.7.tar.gz

Download URL spector-1.7.tar.gz
Size 262.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bd36bd4b01dc776b1658139ff308f7a268a893e3d8f5f172332b2946a41569e9
BLAKE2b-256 checksum
How to use checksums
fdfffb162dfe479051b09b390903c759c91805838c85daada643c3284d8a622b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-win_amd64.whl

Download URL spector-1.7-cp311-abi3-win_amd64.whl
Size 601.2 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ad69743d1ebae7a8842e9789bc76f04cd826cea6d571f77a885225c289526679
BLAKE2b-256 checksum
How to use checksums
766af4526e5a7f7130c3cb36baa448acab310cc1121d297f931cbb10b4a0f5ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-win32.whl

Download URL spector-1.7-cp311-abi3-win32.whl
Size 569.3 kB
Tags CPython 3.11 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
8625ba7fc0a26d08c4a71d872a6af9df45b49341bd384b1d2e09fb95213b1895
BLAKE2b-256 checksum
How to use checksums
313ef73a067b8cd1e81089f87890cd7245c54c1a4941608f0141978010882d86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL spector-1.7-cp311-abi3-musllinux_1_2_x86_64.whl
Size 2.5 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
be071575e9517dfa12a0abf493f8fcac4d49fe7a4d1c3ab21bdd9d047ad8f6fb
BLAKE2b-256 checksum
How to use checksums
91cc80e056def19724dd86d14f3c75d6f361c1baaa38dd30ac79f3cc83c5faa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL spector-1.7-cp311-abi3-musllinux_1_2_aarch64.whl
Size 2.4 MB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
7b94ee01c0c32a54b45e28b472d09c31944b0cadf328b68f6ab31c3dc37afabe
BLAKE2b-256 checksum
How to use checksums
d6f098153c7ed96b1f5ac14be158c7b5da686cd3d6c6f5c3e7e3fbf905f9cada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL spector-1.7-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
233bb0bf633ec8e8551b74a6a0c9c409542aea2b5cd69001be29ffdbbfef69a2
BLAKE2b-256 checksum
How to use checksums
ddcbb099689ad58c2caa7d7160b59f1841b5c13d049ccfdfd134afe858c2a40b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL spector-1.7-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 1.5 MB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
12f061a669ce72e8456dbd313559c2c2491d4b4bb9843637adc67d2efece35b0
BLAKE2b-256 checksum
How to use checksums
34e6b4abb59586373e2637c33ad802186c5f711964c706519a2dfb681972575a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-macosx_11_0_arm64.whl

Download URL spector-1.7-cp311-abi3-macosx_11_0_arm64.whl
Size 425.9 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f0cfa7dc60df79157af5f5a34d2e2a622990f7337f4d8cd67975a4784659e520
BLAKE2b-256 checksum
How to use checksums
0fa797fbb2635b10d87e6d857901284e3e57d0df985023a820442be7338df629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / spector-1.7-cp311-abi3-macosx_10_9_x86_64.whl

Download URL spector-1.7-cp311-abi3-macosx_10_9_x86_64.whl
Size 428.5 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f3d444bdc84cb26e3a93ff5ea7e91dd204b718a75a9c74892b0ee6bb082a3b12
BLAKE2b-256 checksum
How to use checksums
4fb51b2ab6efca735e5bc4368a8c54577ccab8c149eebdb89376d6418473f295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Security for spector 1.7

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.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for spector-1.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

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.

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